Skip to content

How to Download and Upload Files over SSH

download file from ssh server. How to Download file from Server using SSH. The SCP command uses the SSH protocol for copying files.

Category
Networking
Covers
SSH
On this page

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 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 username@example.com:/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 username@example.com:/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 username@example.com:/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.

scp file.zip username@example.com:/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.

Conclusion

In this tutorial, you have learned about transferring files between two systems over the SSH protocol.

Rahul

Rahul Kumar is the founder and chief editor of TecAdmin.net. A Red Hat Certified Engineer (RHCE), he has worked in IT since 2009, with hands-on experience in Linux system administration, DevOps, web hosting, cloud platforms and automation. He started TecAdmin in 2013 to share practical, step-by-step guides, and leads its editorial work with one aim: making technical learning clear and useful for sysadmins, developers and beginners alike.

4 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *


Back to top