This article describes the steps to transfer files via SCP remotely in Ubuntu Linux.
SCP (secure copy) is a command-line utility that securely copies files and directories between two locations, either remotely or locally, on the same host.
If you ever need to transfer files quickly between two Ubuntu servers, the best way is via SSH using Secure Copy (SCP).
SCP uses SSH encryption and authentication to quickly and securely transfer files between servers. Secure copy is a means of securely sharing files and folders between two locations.
How to transfer files to a remote host via SCP in Ubuntu Linux
Run the example commands below to transfer a file to a remote server from the local server you’re currently logged into.
scp file_to_transfer.txt root@remotehost.com:/directory_to_drop_file/location/
The commands above copy a local file from the local server, transfer it to a remote server via the server’s hostname or IP address and drop it into the specified directory location.
How to transfer files from a remote host via SCP in Ubuntu Linux
You use the example commands below to transfer files from a remote host to a local server. Let’s say you want to copy all your website content into a zipped folder called website_content.zip.
You run the commands below to copy the content from the remote server to the local host.
scp root@remotehost.com:/directory/website_content.zip /path_to_store_content/www/html/website_content.zip
Doing the above will secure the remote content from the local host. Next, replace remotehost.com with the hostname or the IP address of the remote server. Also, replace the root with the server’s existing admin account.
For some reason, if the SSH default port is changed from 22, you may have to specify the new port when using the commands above. The example command is shown below.
scp -P 2221 local_file.txt username@remotehost:/directory/location/
Do the same when copying files from the remote host to the local server.
That should do it!
Conclusion:
This post showed you how to transfer files between two networked systems using SCP. If you have any errors above or have something to add, please use the comment form below.
Leave a Reply Cancel reply