Flash Sale:75% Off Hosting + Free DomainEnds in13h47m14sView Plans
Hostvento logoHostvento

Transfer Files Between Two Linux Systems

Move files and folders from one Linux machine to another with rsync, FTP, Samba, scp, SFTP or a quick Python web server.

Files and FTP4 min read36 screenshots

In this guide, Machine A has the user linuxuser and IP 192.168.10.10, and Machine B has the user ubuntu and IP 192.168.10.8. Change them to your own values.

Method 1: rsync

rsync copies only changed parts of files, so it is fast for repeated copies. It uses SSH.

Step 1: Install rsync (on both machines)

sudo apt install rsync -y

Step 2: Check SSH access

From A to B:

ssh ubuntu@192.168.10.8
SSH from Machine A to Machine B

From B to A:

ssh linuxuser@192.168.10.10
SSH from Machine B to Machine A

Step 3: Set up SSH keys (optional but better)

ssh-keygen -t rsa
Generating an SSH key
ssh-copy-id ubuntu@192.168.10.8
Copying the public key to the other machine

Step 4: Send a file from B to A (run on B)

rsync -avz /home/ubuntu/file.txt linuxuser@192.168.10.10:/home/linuxuser
Transferring a file with rsync
  • -a keeps permissions and times, and copies folders.
  • -v shows the progress.
  • -z compresses the data while it travels.

Step 5: Send a folder from A to B (run on A)

rsync -avz /home/linuxuser/docs/ ubuntu@192.168.10.8:/home/ubuntu/
Transferring a directory with rsync

Step 6: Pull in the other direction

rsync -avz ubuntu@192.168.10.8:/home/ubuntu/file.txt /home/linuxuser
Transferring files in the opposite direction

Method 2: FTP

FTP is a common way to move files, but it does not encrypt data by default. Use it only on a trusted network, or use SFTP.

Step 1: Install an FTP server (on the server machine, B)

sudo apt install vsftpd
Installing the FTP server

Edit /etc/vsftpd.conf and set write_enable=YES to allow uploads, then restart:

sudo systemctl restart vsftpd

Step 2: Open port 21

sudo ufw allow 21/tcp
Opening port 21

Step 3: Make a test file

echo "FTP test file" > /home/linuxuser/Documents/ftp-test.txt
Creating a test file

Step 4: Connect from the client

ftp 192.168.10.8
Connecting to the FTP server

Enter the user name and password.

Step 5: Upload

put /home/linuxuser/Documents/ftp-test.txt ftp-test.txt
Uploading a file with FTP

Step 6: Download

get ftp-test.txt
Downloading a file with FTP

Method 3: Samba

Samba shares folders over SMB/CIFS. It is mainly for Windows, but it also works between Linux machines.

Step 1: Install Samba (on both)

sudo apt install samba smbclient cifs-utils -y

Step 2: Share a folder on Machine A

mkdir -p /home/linuxuser/shared
chmod 775 /home/linuxuser/shared
Creating the shared folder

Edit the config:

sudo nano /etc/samba/smb.conf

Add this at the bottom:

[SharedFolder]
    path = /home/linuxuser/shared
    valid users = linuxuser
    read only = no
    browsable = yes
Editing the Samba configuration

Set a Samba password for the user:

sudo smbpasswd -a linuxuser
Setting the Samba password

Restart the service:

sudo systemctl restart smbd
Restarting Samba

Step 3: Access the share from Machine B

smbclient //192.168.10.10/SharedFolder -U linuxuser
Connecting to the Samba share

At the smb: prompt use ls, put and get. Upload:

put /home/ubuntu/Documents/smb-test.txt smb-test.txt
Uploading a file to the share

Download:

get smb-test.txt
Downloading a file from the share

Step 4: Mount the share on Machine B

mkdir -p /home/ubuntu/mountA
Creating the mount point
sudo mount -t cifs //192.168.10.10/SharedFolder /home/ubuntu/mountA -o username=linuxuser
Mounting the shared folder

It asks for the Samba password. (Putting the password in the command line leaves it in your shell history.)

ls /home/ubuntu/mountA
Listing the mounted folder

Step 5: Copy files

sudo cp /home/ubuntu/smb-test.txt /home/ubuntu/mountA/
Copying a file to the share
The file in the shared folder

To copy from A to B, copy out of the mounted folder:

cp /home/ubuntu/mountA/filename.txt /home/ubuntu/

Method 4: scp (secure copy)

scp copies over SSH, so the data is encrypted.

Step 1: Install OpenSSH

sudo apt update && sudo apt install openssh-server -y

Step 2: Start SSH

sudo systemctl enable --now ssh && sudo systemctl status ssh

Step 3: Check the SSH connection

ssh ubuntu@192.168.10.8
Checking SSH connectivity
ssh linuxuser@192.168.10.10
Connecting to the other machine

Step 4: Send a file from A to B

scp /home/linuxuser/localfile.txt ubuntu@192.168.10.8:/home/ubuntu/
Copying a file from A to B

Step 5: Send a file from B to A

scp /home/ubuntu/text.txt linuxuser@192.168.10.10:/home/linuxuser/
Copying a file from B to A

Step 6: Send a folder

scp -r /home/linuxuser/project ubuntu@192.168.10.8:/home/ubuntu/
Copying a directory with scp
scp -r /home/ubuntu/docs linuxuser@192.168.10.10:/home/linuxuser/
Copying a directory from B to A

Method 5: SFTP

SFTP is the safe version of FTP and works through SSH.

Step 1: Make sure the SSH server runs on Machine B

sudo apt update && sudo apt install openssh-server -y

Step 2: Allow port 22 in UFW

sudo ufw allow 22/tcp

Step 3: Start a session from Machine A

sftp ubuntu@192.168.10.8
Starting an SFTP session

Step 4: Upload and download

put /home/linuxuser/file.txt
Uploading a file with SFTP
get /home/ubuntu/file.txt

Method 6: Python web server (quick)

This is handy for a one-time transfer on a trusted network.

Step 1: On the sending machine, open the folder and start a server

cd /path/to/files
Opening the folder to share
python3 -m http.server 8000
Starting the temporary web server

Step 2: On the receiving machine, download the file

wget http://192.168.10.10:8000/file.txt
Downloading the file with wget

Press Ctrl+C on the sender when you are done.

Warning: This server has no password and shows all files in the folder. Use it only briefly and only on a network you trust.

Which method to use

MethodBest for
rsyncRepeated or large copies, backups
scpA quick, secure copy
SFTPAn interactive, secure session
SambaA shared folder that stays mounted
FTPOld setups on a trusted network
Python serverA one-time transfer

Quick recap

  • Use rsync or scp first. Both are encrypted.
  • Avoid plain FTP over the internet.