SSH — Secure Shell
SSH lets you securely connect to remote servers.
Connect to a server
ssh username@hostname
ssh username@192.168.1.100
ssh -p 2222 username@hostname # Custom port
SSH key authentication (recommended)
# Generate a key pair
ssh-keygen -t ed25519 -C "your@email.com"
# Copy public key to server
ssh-copy-id username@hostname
# Now you can connect without password
ssh username@hostname
Key files
~/.ssh/id_ed25519 # Private key (NEVER share!)
~/.ssh/id_ed25519.pub # Public key (share with servers)
~/.ssh/authorized_keys # Keys allowed to connect
~/.ssh/known_hosts # Known server fingerprints
~/.ssh/config # SSH client config
SSH config file
# ~/.ssh/config
Host myserver
HostName 192.168.1.100
User admin
Port 2222
IdentityFile ~/.ssh/id_ed25519
Host *
ServerAliveInterval 60
Now you can just type: ssh myserver
scp — Copy files over SSH
scp file.txt user@host:/path/ # Upload
scp user@host:/path/file.txt . # Download
scp -r directory/ user@host:/ # Recursive
SSH tunneling
# Access remote service locally
ssh -L 8080:localhost:80 user@host
# Reverse tunnel
ssh -R 8080:localhost:80 user@host