How can i upload file by command line via sftp?

ss-t.c picture ss-t.c · Jan 11, 2014 · Viewed 32.8k times · Source

I know how to get remote file via sftp.

ex:

sftp [email protected]:/path/to/file.txt localfile.txt

How can i upload file to remote server?

(I need use this command in my bash script.)

Answer

HelpBox picture HelpBox · Jan 11, 2014

Also think about using SSH public/private keys which can avoid you to have to enter a password for your automated file exchanges.

You can use the command "ssh-keygen" to generate those keys.