說明:
使用ssh自動登入:
方法:
使用RSA key的方式.
步驟:
假設:要從192.168.1.101(Server1)用ssh自動登入192.168.1.102(Server2)
1.在Server1利用 ssh-keygen產生公鑰:
# ssh-keygen -t rsa -b 1024
操作畫面如下,全部均使用預設值即可.
{{{
root@ezkvm-desktop:~/.ssh# ssh-keygen -t rsa -b 1024
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:
ac:04:30:3e:12:60:1c:70:46:d7:5c:ce:45:94:09:40 root@ezkvm-desktop
The key's randomart image is:
+--[ RSA 1024]----+
|B+B .+Eoo++o |
|.* + oo .o |
|. o . o |
| . . . . |
| . S |
| . . |
| . |
| |
| |
+-----------------+
root@ezkvm-desktop:~/.ssh#
}}}
2.把 Server1上的公鑰檔(/root/.ssh/id_rsa.put)的檔案 copy 到 Server 2上的/tmp
3.登入 Server2,把Server1的公鑰 附加 到 Server2的 authorized_keys
{{{
cat /tmp/id_rsa.pub >> /root/.ssh/authorized_keys
}}}