Post

Transfer Files from Ubuntu to Arch Linux over SSH/SFTP

A secure and efficient guide to transferring files between Ubuntu and Arch Linux using rsync and SSH.

Transfer Files from Ubuntu to Arch Linux over SSH/SFTP

Requirements

Both machines must:

  • be powered on
  • be connected to the same local network/Wi-Fi
  • have SSH available on the Arch machine

Note: This guide also works for machines running macOS.

For machines on different networks, see the section on file transfer over Tailscale.


1. Setup SSH server on Arch Linux

On the Arch machine:

Install OpenSSH:

1
sudo pacman -S openssh

Enable and start SSH server:

1
sudo systemctl enable --now sshd

Verify SSH server is running:

1
systemctl status sshd

You should see:

1
active (running)

2. Find Arch machine IP address

On Arch:

1
ip addr

Look for your Wi-Fi or Ethernet interface.

Example:

1
2
3
3: wlp0s20f3: ...
    inet 192.168.1.42/24
subho/

Install rsync if needed

Ubuntu:

1
sudo apt install rsync

Arch:

1
sudo pacman -S rsync

Large transfers with rsync

Standard transfer

1
rsync -avh --progress myfolder/ subho@192.168.1.42:/home/subho/myfolder/

Transfer with compression

1
rsync -avzh --progress myfolder/ subho@192.168.1.42:/home/subho/myfolder/

-z enables compression during transfer.

Useful for:

  • slower Wi-Fi
  • remote transfers
  • text/code/compressible files

Usually NOT useful for:

  • .mp4
  • .mkv
  • .zip
  • .jpg
  • other already-compressed files

Compression may slightly increase CPU usage.

Both commands:

  • copy files
  • preserve source files
  • overwrite changed destination files automatically
  • skip identical files

Options:

  • -a archive mode
  • -v verbose
  • -z compress during transfer
  • -h human readable
  • --progress show progress

Preview changes without modifying anything

1
rsync -avhn --progress myfolder/ subho@192.168.1.42:/home/subho/myfolder/

-n means dry run.


Prevent overwriting existing destination files

1
rsync -avh --ignore-existing myfolder/ subho@192.168.1.42:/home/subho/myfolder/

Move files instead of copying

1
rsync -avh --progress --remove-source-files myfolder/ subho@192.168.1.42:/home/subho/myfolder/

With compression:

1
rsync -avzh --progress --remove-source-files myfolder/ subho@192.168.1.42:/home/subho/myfolder/

This:

  • copies files to Arch
  • deletes transferred source files
  • does NOT remove empty source directories

Remove leftover empty directories:

1
find myfolder -type d -empty -delete

Troubleshooting

Test network connectivity

From Ubuntu:

1
ping 192.168.1.42

Check SSH server again

On Arch:

1
systemctl status sshd

Firewall issues

Temporarily allow SSH:

1
sudo ufw allow 22/tcp

or disable firewall temporarily for testing.


Optional: Passwordless login

Generate SSH key on Ubuntu:

1
ssh-keygen

Copy key to Arch:

1
2
ssh-copy-id subho@192.168.1.42

After this:

  • no password prompts
  • easier SCP/rsync usage
This post is licensed under CC BY 4.0 by the author.