Green YGreck Guides FR
🐧 LinuxIntermediate⏱ 15 min5 steps

Connect over SSH with a key

Safer and more convenient than a password.

  1. Generate a modern key on your machine:
    ssh-keygen -t ed25519 -C "moi@mon-pc"
  2. Copy the public key to the server:
    ssh-copy-id utilisateur@serveur
  3. Connect:
    ssh utilisateur@serveur
  4. Add a shortcut in ~/.ssh/config:
    Host monserveur
      HostName 203.0.113.10
      User utilisateur
      IdentityFile ~/.ssh/id_ed25519
  5. 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.