How to transfer files using the SCP command in Ubuntu Linux

|

|

The article provides a guide on using SCP (Secure Copy), a command-line utility, to securely transfer files and directories between two locations on Ubuntu Linux. It details how to transmit from a local server to a remote host and vice versa. The secure transmission uses SSH encryption and authentication. Instructions are provided for scenarios where…

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 copy the remote content to the local host securely. Next, replace remotehost.com with the hostname or the IP address of the remote server. Also, replace the root with the existing admin account of the server.

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. Suppose you find any error above or have something to add, please use the comment form below.


Discover more from Geek Rewind

Subscribe to get the latest posts to your email.

Like this:



Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Blog at WordPress.com.

Discover more from Geek Rewind

Subscribe now to keep reading and get access to the full archive.

Continue reading