What I Wanted to Do
I needed to connect to a VPS via SSH and wanted to understand the key options and security settings.
Basic SSH Connection
ssh username@IP_address
ssh root@192.168.1.1
ssh root@example.com
Specify a Port
ssh -p 2222 root@example.com
Connect with an SSH Key
ssh -i ~/.ssh/id_ed25519 root@example.com
Simplify with ~/.ssh/config
Typing options every time is tedious. Add a host block to ~/.ssh/config:
Host myserver
HostName 192.168.1.1
User root
Port 22
IdentityFile ~/.ssh/id_ed25519
After this, just run:
ssh myserver
Useful SSH Options
ssh -v root@example.com # Verbose output for debugging
ssh -L 8080:localhost:80 root@example.com # Port forwarding
scp file.txt root@example.com:/tmp/ # Copy a file to remote
Security Settings
Disable Root Login
nano /etc/ssh/sshd_config
# Change: PermitRootLogin no
systemctl restart sshd
Disable Password Authentication
# /etc/ssh/sshd_config
PasswordAuthentication no
Common Pitfalls
- If connection fails, check that port 22 is open in the firewall
- SSH key permissions must be
600— SSH ignores the key otherwise (chmod 600 ~/.ssh/id_ed25519) - VPS hosts display a fingerprint prompt on the first connection — this is normal
For firewall setup, see Linux UFW Firewall Basics.
Related Posts
- Linux File Permissions Explained (chmod/chown)
- How to Fix “Permission Denied” on Linux
- Linux Basic Commands (ls/cd/mkdir/rm)
- Set Up Docker on a VPS
Recommended Cloud Hosting
Looking for reliable cloud infrastructure? Check out these developer-friendly services.
- Cherry Servers - High-performance VPS and dedicated servers
- Cloudways - Managed cloud hosting for developers