создание и копирование ssh ключа на удалённый сервер

Запись создана 29 июля, 2008

Создаём пару ключей (публичный и приватный) на локальной машине. Вместо пароля жмём Enter (удобно для безпарольной авторизации по ssh).
[cc lang=»bash»]
[root@dev2 ~]# ssh-keygen  -t dsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
b8:5d:63:6b:98:09:b9:48:f0:9d:b1:91:fa:22:e1:3d root@dev2
[/cc]

Теперь копируем свой публичный ключ ssh на удалённую машину в список допустимых ключей.
[cc lang=»bash»]
[root@dev2 .ssh]# ssh-copy-id -i ~/.ssh/id_rsa.pub localhost
21
The authenticity of host ‘localhost (127.0.0.1)’ can’t be established.
RSA key fingerprint is 24:e5:61:b4:26:72:9e:fa:c9:d0:76:93:c4:49:05:ba.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added ‘localhost’ (RSA) to the list of known hosts.
root@localhost’s password:
Now try logging into the machine, with «ssh ‘localhost'», and check in:

.ssh/authorized_keys

to make sure we haven’t added extra keys that you weren’t expecting.
[/cc]

теперь по команде ssh localhost мы без ввода паролей сможем зайти на сервер localhost.
примечание: Замените localhost на хостнэйм/ip удалённой машины.

» Запись из раздела Unix | Комментировать

Комментарии





Ответить