
Tutorial10 min read • Dec 12, 2024
SSH on Linux: How to Connect to a Server — Definitive Guide
SSH on Linux: connect to a server via SSH, set up keys, security best practices and remote management. Everything you need for SSH on Linux.

Diego Velez
Technical leadership
What Is SSH?
Secure Shell (SSH) is the standard protocol for interacting securely with remote Linux servers. It encrypts all traffic, so your passwords and data stay safe.
Basic command
With username and password:
ssh username@ip-address
Beyond Passwords: SSH Keys
Passwords are vulnerable to brute force. The "pro" way is SSH key pairs.
1. Generate your key
On your local machine:
ssh-keygen -t ed25519 -C "your_email@example.com"
This creates a private key (~/.ssh/id_ed25519) and a public key (~/.ssh/id_ed25519.pub).
2. Copy the key to the server
ssh-copy-id username@ip-address
After that you can log in without a password. Faster and much more secure.
Harden the Server
Once in, tune /etc/ssh/sshd_config:
- Disable root login:
PermitRootLogin no - Disable password auth:
PasswordAuthentication no - Change default port: e.g. from 22 to 2222 to avoid most bot scans
Restart the service:
sudo systemctl restart ssh
Pro Tips
- SSH config: Save connections in
~/.ssh/configso you can typessh myserver - Mosh: Use it on mobile or unstable networks
- Tmux: Start a Tmux session so your work survives disconnects
Construye tu futuro.
¿Listo para transformar tu infraestructura con agentes de IA inteligentes?
Book assessment