Remote Access: SSH, SCP, Rsync, RDP & WireGuard
Control servers from anywhere, copy files without losing data, and wrap traffic inside encrypted tunnels. Every command below is copy-ready and works across Linux, macOS, and Windows PowerShell.
Command Anatomy: How an SSH Command Reads
ssh -i ~/.ssh/id_ed25519 -p 22 user@host
1 SSH & Key Management
Passwords can be guessed by bots. SSH keys work like a padlock (.pub
public key you put on servers) and a physical key (private key that never leaves your laptop).
id_ed25519 (private) and
id_ed25519.pub (public). Faster and stronger than RSA.
.pub key to the server's
~/.ssh/authorized_keys for passwordless login.
8080 securely to port
5432 (e.g., Postgres) inside the remote server.
-L means Local first:
ssh -L local_port:target_host:target_port user@ssh_server. You open
localhost:local_port on your own machine.
Shortcut Aliases with ~/.ssh/config
Save long flags once so you can just type ssh prod-db.
Host bastion
HostName 203.0.113.10
User ops
IdentityFile ~/.ssh/id_ed25519
Host prod-app
HostName 10.0.1.25
User deploy
ProxyJump bastion
IdentityFile ~/.ssh/id_ed25519
2 Secure File Transfer (SCP, Rsync, SFTP)
All three transfer files over encrypted SSH (port 22). Use SCP for quick one-offs, Rsync for large folders/backups, and SFTP for interactive browsing.
/opt/ folder. Add
-r for directories, -P 2222 (uppercase P!) for custom ports.
./).
-a archive (keeps permissions), -v verbose,
-z compress. Only sends changed blocks and resumes if dropped.
ls, cd,
get file (download), or put file (upload).
./site/ (with slash) copies the contents inside /var/www/.
./site (no slash) creates /var/www/site/.
3 Remote Protocols Quick Table
Know which port and transport each remote tool usesโespecially when configuring firewalls or security groups.
| Protocol | Default Port | Encrypted? | Best For |
|---|---|---|---|
| SSH | 22 / TCP |
Yes (Strong) | Linux/macOS/Windows CLI administration & port tunneling |
| SFTP | 22 / TCP |
Yes (Over SSH) | Interactive encrypted file browsing and transfers |
| RDP | 3389 / TCP & UDP |
Yes (TLS) | Windows full graphical desktop (always put behind VPN!) |
| VNC | 5900 / TCP |
No by default | Cross-platform screen sharing (tunnel over SSH or VPN) |
| WireGuard | 51820 / UDP |
Yes (ChaCha20) | Modern, ultra-fast kernel VPN tunnels & site-to-site links |
| OpenVPN | 1194 / UDP (or 443/TCP) |
Yes (TLS) | Legacy enterprise VPNs; TCP 443 bypasses strict firewalls |
4 WireGuard & VPN Quick Reference
A VPN creates an encrypted private network overlay so you can reach internal servers (like
10.0.1.25 or RDP 3389) without exposing them to the public internet.
/etc/wireguard/wg0.conf. Use down to disconnect.
Full Tunnel vs. Split Tunnel (AllowedIPs)
Full Tunnel 0.0.0.0/0
Routes 100% of your internet traffic through the VPN server.
Best for untrusted public Wi-Fi (cafes, airports) where you want all browsing encrypted.
Split Tunnel 10.0.0.0/8
Routes only private office/cloud subnets through the VPN; normal web browsing stays direct.
Best for daily DevOps workโfast video calls while still reaching private servers.
5 The Danger Zone
Automated bots scan port 3389 24/7 for brute-force
and ransomware attacks. Never open 3389 to 0.0.0.0/0โalways
connect through a WireGuard/OpenVPN tunnel + MFA first.
id_ed25519)
Only ever share the .pub file! Never paste
id_ed25519 into Git, Slack, or email. If leaked, delete it from every
server's authorized_keys immediately.
chmod 777 ~/.ssh Breaks SSH
SSH refuses to use keys if other users on the system can read
them ("Permissions are too open"). Fix it with:
chmod 700 ~/.ssh && chmod 600 ~/.ssh/id_ed25519.