views:

141

answers:

2

Hi Trying to send a file to another server using scp.. cannot use sftp as it is not installed on my server so i am getting a function not found for ssh2_connect.

So my only option as i can see it is scp. Now the problem come with i cannot include my password in the php scp script.

ie:

scp filename username:passwor@server:filename

It gives me the error that the server username doesn't exist If i use it without the password

scp filename username@server:filename

it prompts me for password

PS: I am testing the script in a command line on the localhost first as to get the error messages.

Any advice?

TA

A: 

Kevin, if you don't have the PHP SSH2 extension installed on your server then your best bet is to setup public/private key authentication on your other server if you have access. Then you can keep the private key on your PHP server, and pass -i on your scp command, something like this:

scp -i /var/www/htdocs/myphpproject/rsakey filename username@server:filename

Sam Day
A: 

If you can't use the SFTP binaries you could use phpseclib - a pure-PHP SFTP implementation:

http://phpseclib.sourceforge.net/

notedshow