Remote & SSH
Remote Transfer Patterns
# Push to remote
rsync -avz /local/path/ user@host:/remote/path/
# Pull from remote
rsync -avz user@host:/remote/path/ /local/path/
# Specific SSH key
rsync -avz -e "ssh -i ~/.ssh/mykey" src/ user@host:dest/
# Non-standard SSH port
rsync -avz -e "ssh -p 2222" src/ user@host:dest/
# Fast cipher (better speed)
rsync -avz -e "ssh -c aes128-gcm@openssh.com" src/ user@host:dest/
SSH Options
| Option | Command | Purpose |
|---|---|---|
| Custom key | -e "ssh -i /path/to/key" | Use specific SSH key |
| Custom port | -e "ssh -p 2222" | Non-standard SSH port |
| Fast cipher | -e "ssh -c aes128-gcm@openssh.com" | Faster encryption |
| Keepalive | -e "ssh -o ServerAliveInterval=30" | Prevent disconnects |
| No host check | -e "ssh -o StrictHostKeyChecking=no" | CI/CD automation |
| Verbose SSH | -e "ssh -v" | Debug connection |
SSH Config (Reusable)
~/.ssh/config
Host backup
HostName 10.0.0.50
User backupuser
Port 2222
IdentityFile ~/.ssh/backup_key
ControlMaster auto
ControlPath ~/.ssh/sockets/%r@%h-%p
ControlPersist 600
# Now use the alias
rsync -avz /src/ backup:/dest/