Просто убедитесь, что вы выполнили следующую процедуру:
На машине A
откройте терминал и введите команды следующим образом:
root@aneesh-pc:~# id
[d4 ] Чтобы убедиться, что мы являемся root. Если вышеприведенная команда выводит что-то вроде ниже, мы root root переключимся на root с помощью команды su
uid=0(root) gid=0(root) groups=0(root)
1) Создайте ключи.
ssh-keygen -t rsa
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:
49:7d:30:7d:67:db:58:51:42:75:78:9c:06:e1:0c:8d root@aneesh-pc
The key's randomart image is:
+--[ RSA 2048]----+
| ooo+==B|
| . E=.o+B|
| . . .+.*o|
| . . . ...|
| S |
| |
| |
| |
| |
+-----------------+
Я не использовал кодовую фразу. Если это необходимо, вы можете использовать его.
2) Скопируйте открытый ключ в файл .ssh/authorized_keys машины B
root@aneesh-pc:~# ssh-copy-id -i /root/.ssh/id_rsa.pub root@mylap
root@mylap's password:
Теперь попробуйте войти в систему, с помощью ssh 'root@mylap', и зайдите в:
~/.ssh/authorized_keys
, чтобы убедиться, что мы не добавили лишние ключи, которых вы не ожидали.
Заменить mylap именем хоста или ip машины вы хотите войти в систему (т.е. машина B)
3) Вход в B без пароля
root@aneesh-pc:~# ssh root@mylap
Warning: Permanently added 'mylap,192.168.1.200' (RSA) to the list of known hosts.
Welcome to Ubuntu 11.04 (GNU/Linux 2.6.38-8-generic x86_64)
* Documentation: https://help.ubuntu.com/
Last login: Wed Jul 27 15:23:58 2011 from streaming-desktop.local
aneesh@mylap:~$
На машине A
4) Создайте ключи для входа в систему A
root@mylap:~# ssh-keygen -t rsa
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:
35:9f:e7:81:ed:02:f9:fd:ad:ef:08:c6:4e:19:76:b1 root@streaming-desktop
The key's randomart image is:
+--[ RSA 2048]----+
| |
| |
| o . |
| . + + o |
| S o * E |
| = O . |
| O + |
| + o o.|
| . o+=|
+-----------------+
5) Скопируйте открытый ключ в файл .ssh/authorized_keys компьютера [A]
root@mylap:~# ssh-copy-id -i /root/.ssh/id_rsa.pub root@aneesh-pc
Warning: Permanently added 'aneesh-pc,192.168.1.20' (RSA) to the list of known hosts.
root@aneesh-pc's password:
Теперь попробуйте войти в ssh 'root@aneesh-pc', и зайдите в
.ssh/authorized_keys
, чтобы убедиться, что мы не добавили лишние ключи, которых вы не ожидали.
6) Войти в A без пароля
ssh root@aneesh-pc
Warning: Permanently added 'aneesh-pc,192.168.1.20' (RSA) to the list of known hosts.
Welcome to Ubuntu 11.04 (GNU/Linux 2.6.38-8-generic x86_64)
* Documentation: https://help.ubuntu.com/
Last login: Tue Jul 26 18:52:55 2011 from 192.168.1.116
Если вы можете выполнить эти шаги, все готово. Теперь у вас есть две машины с включенным именем ssh-key (с открытым ключом).