Owen
Owen

Reputation: 7577

cURL for SFTP with private key authentication

I need to upload files by SFTP from a PHP script. I think cURL is probably the way, as I have this available on the server.

Has anyone got an example of how to use cURL for SFTP using identity key authentication?

-- EDIT --

I've just noticed that HTTP PUT might be an alternative, but how secure it that?

Upvotes: 9

Views: 44651

Answers (1)

idontevenseethecode
idontevenseethecode

Reputation: 962

curl -u <username>: --key ~/.ssh/id_rsa --pubkey ~/.ssh/id_rsa.pub sftp://<remote_host>/<remote_path>

HTTP is unsecured, so any data you send during PUT (e.g. a password or the files you are uploading) could be snooped and read in plain text. Depending on your application, this may or may not be a concern for you.

Upvotes: 13

Related Questions