Connect over SSH with a key
Safer and more convenient than a password.
- Generate a modern key on your machine:
ssh-keygen -t ed25519 -C "moi@mon-pc"
- Copy the public key to the server:
ssh-copy-id utilisateur@serveur
- Connect:
ssh utilisateur@serveur
- Add a shortcut in ~/.ssh/config:
Host monserveur HostName 203.0.113.10 User utilisateur IdentityFile ~/.ssh/id_ed25519
- Once the key is tested, disable passwords on the server (/etc/ssh/sshd_config) then restart the service:
PasswordAuthentication no sudo systemctl restart ssh
⚠️ Keep a session open while you test the new configuration so you do not lock yourself out.