![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Linux RedHat, Ubuntu, SUSE, Fedora, Debian, Mandriva, Slackware, Gentoo linux, PCLinuxOS. All Linux questions here! |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
PHP and SCP
How do I get PHP to use SCP?
I have tried using expect in a shell script and then passing it hostname, username and password. The shell script works if it's run it from the command line (logged in as apache) but if I run it from a PHP script it doesn't work and I can't figure out why. The web front end needs to: - collect hostname, username, password - log into remote machine - transfer tar file from host machine to local machine - expand tar file on local machine Any suggestions would be greatly appreciated... Thanks, ~Donavon |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
I would suggest you use public keys instead of passwords for something like this. Then the user would not need to enter any username/password. Of course you front-end should be authenticated via some other means(ldap,file, etc..)
be very careful with your input parameters check out PHP: Program Execution - Manual |
|
#3
|
|||
|
|||
|
Public keys can't be used in this situation.
|
|
#4
|
|||
|
|||
|
my guess is that your script might be breaking because there is no terminal while running under apache and expect will not be able to read stdin.
|
|
#5
|
|||
|
|||
|
this is just an example
Code:
<?php
$conn = ssh2_connect('ftp.server.com', 22);
ssh2_auth_password($conn 'user', 'pass');
ssh2_scp_send($conn, '/local/filename', '/remote/filename', 0644);
?>
|
|
#6
|
|||
|
|||
|
sweet. I did not realize PHP had an API for ssh. learn something new every day.
|