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.)
How to Connect to SFTP. By default, the same SSH protocol is used to authenticate and establish an SFTP connection. To start an SFTP session, enter the username and remote hostname or IP address at the command prompt. Once authentication is successful, you will see a shell with an sftp> prompt.
Type 'exit' command where we can see sftp> prompt return.
sftp> put – Upload file. sftp> get – Download file. sftp> cd path – Change remote directory to 'path' sftp> pwd – Display remote working directory.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With