Connexion SSH avec clé public / privée
Permet de se connecter en SSH sans demander de mot de passe : identification via clé publique /clé privée + passphrase.
1°) générer un certificat RSA :
-
ssh-keygen -t rsa
Generating public/private rsa key pair. Enter file in which to save the key (/home/b/.ssh/id_rsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /home/b/.ssh/id_rsa. Your public key has been saved in /home/b/.ssh/id_rsa.pub.
Possibilité de crypter plus les certifs : ssh-keygen -t rsa -b 2048 / ssh-keygent -t rsa -b 4096
- Envoyer le certificat sur la machine distante ( serveur SSHD ) afin d’enregistrer sa clé.
ssh-copy-id -i ~/.ssh/id_rsa.pub username@host
-
Test de la connexion : ssh user@hostname : on doit simplement nous demander la passphrase .
- Si pas le cas : vérifier :
PubkeyAuthentication yes RSAAuthentication yes
-
==> nano /etc/ssh/sshd_config puis
-
==> sudo /etc/init.d/ssh restart
Modifier le home :
$ chmod go-w ~/ $ chmod 700 ~/.ssh $ chmod 600 ~/.ssh/authorized_keys
- PasswordAuthentication no ==>
attention une fois que t as fait ca , si t as plus la main t es nické :p
