Software & Configuration

File Transfer (SCP / SFTP / rsync)

How to transfer files to and from the server via SCP, SFTP and rsync

There are several methods to transfer files between your computer and the server. The most common is SCP, but SFTP and rsync are often better for specific cases.


SCP: simple copy

SCP (Secure Copy) transfers files using SSH. Basic syntax:

# From your PC to server
scp /local/path/file.txt root@IP:/remote/path/

# From server to your PC
scp root@IP:/remote/path/file.txt /local/path/

# Entire folder (flag -r)
scp -r /local/folder/ root@IP:/var/www/html/

# Custom SSH port
scp -P 2222 file.txt root@IP:/tmp/

SFTP: interactive client

SFTP works like traditional FTP but encrypted. Useful for exploring the server filesystem:

sftp root@IP

Commands inside SFTP:

ls              # List files on server
lls             # List local files
cd /var/www     # Change directory on server
lcd ~/Desktop   # Change local directory
get file.txt    # Download file from server
put file.txt    # Upload file to server
mget *.log      # Download multiple files
mput *.php      # Upload multiple files
rm file.txt     # Delete file on server
exit            # Exit

rsync: intelligent synchronization

rsync is ideal for transferring large amounts of files or syncing directories: it transfers only modified files, much faster than SCP for incremental updates.

# From PC to server
rsync -avz /local/path/ root@IP:/remote/path/

# From server to PC
rsync -avz root@IP:/remote/path/ /local/path/

# With progress
rsync -avz --progress /source/ root@IP:/destination/

# Exclude folders
rsync -avz --exclude='node_modules' --exclude='.git' /project/ root@IP:/var/www/project/

# Custom SSH port
rsync -avz -e "ssh -p 2222" /source/ root@IP:/destination/

# Delete files in destination that no longer exist in source
rsync -avz --delete /source/ root@IP:/destination/

Common options:

  • -a: archive (preserves permissions, timestamps, symlinks)
  • -v: verbose (shows transferred files)
  • -z: compress data during transfer
  • --progress: shows progress bar

Graphical clients (Windows / macOS)

If you prefer a graphical interface:

ClientSystemNotes
WinSCPWindowsSFTP/SCP with dual-pane interface
FileZillaWin/Mac/LinuxSFTP supported, familiar interface
CyberduckMac/WindowsFree, supports SFTP and many clouds
TransmitmacOSPaid, very performant

Configuration in these clients:

  • Protocol: SFTP
  • Host: server IP
  • Port: 22 (or your custom port)
  • User: root
  • Authentication: password or private key

Transfer files between two servers

# From server A, copy a file to server B
scp /file/on/server-a root@IP_SERVER_B:/destination/

# With rsync
rsync -avz /source/ root@IP_SERVER_B:/destination/

On this page