SSH/SCP: Copy Files & Folders from Local to Remote & Remote to Local
This article shows how you can copy files and folders from your local machine to remote server. Also, how you can copy files and folders from the remote server to your local machine.
We will use SCP protocol for this purpose. SCP stands for Secure Copy Protocol. It’s a means of securely transferring computer files. Files can be transferred between local host and remote host, or between two remote hosts.
SCP is based on the Secure Shell (SSH) protocol.
Copy from Local to Remote
Copy a single file from Local computer to Remote Server
1 | scp /path/of/your/local/filename username@hostname:/path/to/remote/server/folder |
with a custom port number (xxxx)
1 | scp -P xxxx /path/of/your/local/filename username@hostname:/path/to/remote/server/folder |
Copy folder from Local Computer to Remote Server
-r = recursive copy (copy all the files and folders inside the specified folder)
1 | scp -r /path/of/your/local/folder username@hostname:/path/to/remote/server/folder |
with a custom port number (xxxx)
1 | scp -r -P xxxx /path/of/your/local/folder username@hostname:/path/to/remote/server/folder |
Copy from Remote to Local
Copy a single file from Remote Server to Local Computer
1 | scp username@hostname:/path/of/remote/server/filename /path/to/local/destination/folder |
with a custom port number (xxxx)
1 | scp -P xxxx username@hostname:/path/of/remote/server/filename /path/to/local/destination/folder |
Copy folder from Local Computer to Remote Server
-r = recursive copy (copy all the files and folders inside the specified folder)
1 | scp -r username@hostname:/path/of/remote/server/folder /path/to/local/destination/folder |
with a custom port number (xxxx)
1 | scp -r -P xxxx username@hostname:/path/of/remote/server/folder /path/to/local/destination/folder |
Hope this helps. Thanks.





Mukesh Chapagain is a graduate of Kathmandu University (Dhulikhel, Nepal) from where he holds a Masters degree in Computer Engineering. Mukesh is a passionate web developer who has keen interest in open source technologies, programming & blogging.