Authentification par clé public privé

Exemple : de Tic vers Tac

Sur TIC:

cd root/.ssh/
ssh-keygen -t dsa
Generating public/private dsa key pair.

Enter file in which to save the key (/root/.ssh/id_dsa): /root/.ssh/id_dsa_tic
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_dsa_tic.
Your public key has been saved in /root/.ssh/id_dsa_tic.pub.
The key fingerprint is:6e:82:aa:d9:c3:af:57:34:26:f8:1e:b5:24:c9:88:b9 root@ticThe key’s randomart image is:

+–[ DSA 1024]—-+
| |
| |
| o + . |
|o o = * |
| . . B oS |
|E o.o. |
| . ..o. o |
| oo.o o |
|o.+=. |
+—————–+

root@tic:~/.ssh# ls
id_dsa_tic id_dsa_tic.pub
root@tic:~/.ssh# chmod 600 id_dsa_tic.pub

root@tic:~/.ssh# ls -la
total 20
drwx—— 2 root root 4096 2013-08-02 14:04 .
drwx—— 34 root root 4096 2013-05-07 16:57 ..
-rw——- 1 root root 668 2013-08-02 14:04 id_dsa_tic
-rw——- 1 root root 598 2013-08-02 14:04 id_dsa_tic.pub

______________________________________________________________

Copie de la clé publique sur le serveur distant (TAC).
root@tic:~/.ssh# scp id_dsa_tic.pub root@tac:/root/.ssh/
root@tac’s password:
id_dsa_tic.pub 100% 598 0.6KB/s 00:00

Sur TAC :
Le fichier est bien présent sur TAC.
root@tac:~# ll /root/.ssh/
total 16
drwx—— 2 root root 4096 2013-08-02 14:17 .
drwx—— 32 root root 4096 2013-08-02 10:32 ..
-rw——- 1 root root 598 2013-08-02 14:17 id_dsa_tic.pub

Ajout de la clé dans le fichier des clés autorisées.
root@tac:~# cd /root/.ssh/
root@tac:~/.ssh# cat id_dsa_tic.pub >> authorized_keys

Laisser un commentaire

Votre adresse de messagerie ne sera pas publiée. Les champs obligatoires sont indiqués avec *