Subject: Re: Request for help for beginner, thanks!

Re: Request for help for beginner, thanks!

From: Henrik Nordström <>
Date: Mon, 18 Jan 2021 01:36:27 +0100

sön 2021-01-17 klockan 15:08 -0500 skrev David Spector:
> I don't mind waiting for working code, having spent so many days
> working on this on my own and needing to work on other stuff.
> Let's see if someone on this mailing list has ever written PHP code
> to upload a file using sFTP. I will keep my fingers crossed...

The PHP ssh2 module referenced earlier does work.

And if you read the comments you also have a nice wrapper class and
supplementary methods for public key auth and file upload that
demonstrates it's usage, but even without that is't not complicated to
use. Read all the comments if using the class as there is some
important suggestions and caevats that you may need to account for,
mainly the importance of understanding the meaning of the remote path

What error do you run into?

Also, don't forget to secure the stored login credentials
appropriately, and preferably restrict them on the sftp server to only
allow sftp and only to the desired folders. But that's outside of

And be warned that many SSH servers do not support the old ssh-rsa
authentication method today due to demonstrated SHA1 weakness, and
libssh2 defaults to use ssh-rsa if given an RSA key. Not sure if it is
possible to tell libssh to use the rsa-sha2-256 authentication method
instead (uses same key format, different authentication method). Use of
an ecdsa key avoids this hurdle.


Received on 2021-01-18