The Troll's factory

Geekeries & pensées
-->

S’identifier en SSH sans mot de passe à l’aide d’une clé RSA — SSHA Authentication without password using a RSA key

Non seulement c’est plus sécurisé, mais en plus c’est quand même carrément plus pratique, voici comment configurer en 30 secondes (top chrono !) votre accès SSH sur votre serveur favoris à l’aide d’une clé RSA plutôt avec qu’un vieux mot de passe soit pas sécurisé, soit que vous n’arrivez pas à retenir :

Générer la clé : 10 secondes
$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/thouveni/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/[utilisateur]/.ssh/id_rsa.
Your public key has been saved in /home/[utilisateur]/.ssh/id_rsa.pub.
The key fingerprint is:

La « propager » : 10 secondes :
$ cat $HOME/.ssh/id_rsa.pub | ssh [utilisateur@]machine "mkdir -p .ssh; chmod 700 .ssh; cat >> .ssh/authorized_keys"
Note : si vous utilisez un port particulier (comme le port 42 par exemple), il faut rajouter « -p 42″ AVANT la commande entre guillemets, et APRÈS « [utilisateur]@machine » (entre les deux)

Tester que ça marche : 10 secondes
ssh [utilisateur@]machine

Enjoy ;)

———————————– For our English readers : ———————————-

Not only it’s more secured, but much more praticle as well, here is how to configure in 30 seconds (timer in hand !) your SSH access to your favourite server using a RSA key instead of an old-fashionned password which is either not secured either secured but impossible to remember !

Generating the key: 10 seconds
$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/[user]/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/[user]/.ssh/id_rsa.
Your public key has been saved in /home/[user]/.ssh/id_rsa.pub.
The key fingerprint is:

« Broadcasting » it: 10 seconds
$ cat $HOME/.ssh/id_rsa.pub | ssh [user@]host "mkdir -p .ssh; chmod 700 .ssh; cat >> .ssh/authorized_keys"
Note : if you use a specific port (as for instance the 42 one), you have to add « -p 42″ BEFORE the command in quotes, and AFTER « [user]@host » (between the two)

Testing it works: 10 seconds
ssh [user@]host

Enjoy ;)

posté par Troll dans Administration serveur,astuces,Geekeries avec aucun commentaire