FTP / SCP / rsync — Transfer Cheat Sheet

FTP / SFTP

File Transfer Protocol

CommandDescription
ftp <host>Open FTP session to host
sftp user@hostSecure FTP over SSH
sftp -P 2222 user@hostSFTP on non-default port
sftp -i ~/.ssh/id_rsa user@hostSFTP with identity file
put /local/file.tar /remote/Upload single file
mput *.tar.gzUpload multiple files (glob)
put -r /local/dir /remote/dirUpload directory (sftp only)
get /remote/file.tar /local/Download single file
mget *.logDownload multiple files (glob)
get -r /remote/dir /local/dirDownload directory (sftp only)
ls / llsList remote / local directory
cd /remote/path / lcd /localChange remote / local directory
pwd / lpwdPrint remote / local working dir
bye / quitClose session
sftp user@host <<EOF put /backup/db.tar.gz /drop/ bye EOFHere-doc batch transfer in shell script
sftp -b /tmp/batch.txt user@hostExecute commands from batch file
Note: Plain FTP sends credentials in cleartext — use SFTP or SCP in production. Disable anonymous FTP on backup servers.
SCP

Secure Copy Protocol

CommandDescription
scp file.tar user@host:/backup/Copy single file to remote
scp -r /local/dir user@host:/backup/Copy directory recursively
scp -P 2222 file.tar user@host:/tmp/Non-default SSH port
scp -i ~/.ssh/id_rsa file.tar user@host:/tmp/Specify identity file
scp -C file.tar user@host:/backup/Enable compression in transit
scp -l 8192 big.tar user@host:/bkp/Limit bandwidth (Kbit/s)
scp user@host:/backup/file.tar /local/Pull single file from remote
scp -r user@host:/backup/dir /local/Pull directory from remote
scp user@src:/data/file.tar user@dst:/data/Copy between two remote hosts
scp -rp /local/dir user@host:/dst/Preserve timestamps & permissions
scp -q file.tar user@host:/bkp/Quiet mode — suppress progress
scp -v file.tar user@host:/bkp/Verbose — useful for debugging
Note: SCP lacks resume capability. For large transfers or unreliable links use rsync over SSH instead. On newer OpenSSH (>= 9.0) scp uses the SFTP protocol internally.
rsync

Remote Sync

CommandDescription
-a (--archive)Recursive + preserve perms, times, symlinks, owner, group
-z (--compress)Compress data in transit
-v (--verbose)Show files being transferred
-P--partial + --progress (resume + show progress)
-n (--dry-run)Simulate — no changes written
--deleteDelete files on dst not present on src
--checksumCompare by checksum, not mtime/size
--bwlimit=5000Limit bandwidth (KBytes/s)
rsync -avz /src/ user@host:/dst/Sync directory to remote (trailing / = contents only)
rsync -avzP /src/ user@host:/dst/With progress & resume support
rsync -avz --delete /src/ user@host:/dst/Mirror — removes files deleted on src
rsync -avz -e "ssh -p 2222" /src/ user@host:/dst/Non-default SSH port
rsync -avz -e "ssh -i /root/.ssh/id_rsa" /src/ user@host:/dst/Custom identity file
rsync -avz user@host:/src/ /local/dst/Pull remote directory locally
rsync -avzP user@host:/src/big.tar /local/Pull single file with resume
rsync -av /mnt/data/ /mnt/backup/Local disk sync
rsync -av --exclude='*.log' /src/ user@host:/dst/Exclude by pattern
rsync -av --exclude-from=/tmp/excl.txt /src/ user@host:/dst/Exclude list from file
rsync -av --include='*.tar.gz' --exclude='*' /src/ user@host:/dst/Include only .tar.gz files
rsync -avz --numeric-ids /src/ user@host:/dst/Preserve UID/GID numerically (cross-host)
rsync -avz --log-file=/var/log/rsync.log /src/ user@host:/dst/Write transfer log
rsync -avzn /src/ user@host:/dst/ 2>&1 | tee /tmp/dryrun.outDry-run with captured output for review
Trailing slash on source matters: /src/ syncs contents into /dst/; /src (no slash) creates /dst/src/. On AIX, ensure rsync is installed via toolbox/rpm and SSH key auth is in place for scripted jobs.