File Transfer (SCP / SFTP / 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.
02
SCP: simple copy
SCP (Secure Copy) transfers files using SSH. Basic syntax:
bash
# 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/
03
SFTP: interactive client
SFTP works like traditional FTP but encrypted. Useful for exploring the server filesystem:
bash
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
04
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.
bash
# 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
05
Graphical clients (Windows / macOS)
If you prefer a graphical interface:
| Client | System | Notes |
|---|---|---|
| WinSCP | Windows | SFTP/SCP with dual-pane interface |
| FileZilla | Win/Mac/Linux | SFTP supported, familiar interface |
| Cyberduck | Mac/Windows | Free, supports SFTP and many clouds |
| Transmit | macOS | Paid, very performant |
Configuration in these clients:
- Protocol: SFTP
- Host: server IP
- Port: 22 (or your custom port)
- User: root
- Authentication: password or private key
06
Transfer files between two servers
bash
# 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/
Related articles
