How to Download and Upload Files over SSH
Abstract: 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_k
SSH is the most secure protocol for accessing remote servers. It provides the highest level of end-to-end data security over communication channels. The SCP (Secure Copy) command uses the SSH protocol for copying files between remote and local servers.
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 ProtocolHere 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
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.
scp file.zip [email protected]:/remote/dir
Similarity you can use -P switch to define port of the SSH server and -i to define private key for the user authentication.
ConclusionIn this tutorial, you have learned about transferring files between two systems over the SSH protocol.