Weblutions Documentation > Knowledgebase > Transfer Directories Between Ubuntu Servers

Transfer Directories Between Ubuntu Servers

Transferring content between two Linux servers can seem daunting if you're new to Linux. This guide will walk you through using the scp command (specifically on Ubuntu) to send files or entire directories from one Ubuntu server to another. Don’t worry — it’s simpler than you think!

What is SCP (Secure Copy)?

The scp (secure copy) command in Linux is used to securely transfer files or directories between systems over SSH. It works similarly to the cp command but allows copying to or from remote machines, with all data encrypted during transfer.

Why Use SCP?

While there are other tools like rsync for transferring files between servers, scp is straightforward and reliable — perfect for simple tasks. This guide keeps things beginner-friendly by focusing on scp.

How to Use SCP

To transfer content between two servers, you’ll need the SSH connection details for both machines. Let’s assume there’s "Server 1" and "Server 2", and you want to transfer content from Server 1 to Server 2.

Transferring a Single File

Run this command on Server 1 (the source), replacing the placeholders with the actual file path and Server 2 details:

scp /path/to/local.file SERVER_2_USERNAME@SERVER_2_IP:/path/to/save.file

Example:

scp /var/www/html/index.html root@123.321.789.1:/var/www/html/index.html

Transferring a Directory

To transfer an entire directory and its contents (e.g., the whole /home folder), add the recursive flag (-r) to the command:

scp -r /home SERVER_2_USERNAME@SERVER_2_IP:/home

Example:

scp -r /home root@123.321.789.1:/home

What to Expect

When you run these commands, you may be prompted to confirm the server’s fingerprint and enter Server 2’s password. Once authenticated, the transfer will begin, and progress will be shown in your terminal.

And that’s it! You’ve successfully transferred files or directories between Ubuntu servers using SCP.


Suggest an edit

Review this page

faxes

send files between servers send file from one server to another transfer server files

1 recommend this page