The remote server must have a running SSH server. This tutorial will help you to understand download and upload files over SSH protocol.
Download file over SSH Protocol
Here are some useful examples for downloading files from the remote system over SSH protocol.
This will connect to example.com server with user “username” and copy the /backup/file.zip file to local system directory /local/dir. To use theis command replace the values as per your environment.scp [email protected]:/backup/file.zip /local/dir If the SSH is running on a non-standard port, You can specify the port using -P option with SCP command.scp -P 2222 [email protected]:/backup/file.zip /local/dir If your remote server required a private key to connect server, You can use -i followed by a private key file path to connect your server using the SCP command. This can be helpful for AWS servers.scp -i private_key.pem [email protected]:/backup/file.zip /local/dir
Upload file using SSH
You can also upload files to the remote server using SSH protocol using the SCP command. Use the following example command for uploading files to the SSH server. Similarity you can use -P switch to define port of the SSH server and -i to define private key for the user authentication.
Conclusion
In this tutorial, you have learned about transferring files between two systems over the SSH protocol.