2010年4月22日 星期四

SSH Login Without Password

因為文章裡會 reference 比較多次,所以乾脆獨立出來。

當你的機器設備較多時,密碼認證就變成一種相當大的負擔,用 keys 來認證,相對成為認證方式首選!

Step1. 產生 key pair
產生認證所需的 key

[root@nodeB ~] # 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): # 請注意,這是存取 private key 的密碼,如果你想做 auto login, 請不要輸入任何東西。
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:
2d:52:2c:9f:d9:f8:7a:35:83:d8:12:7e:cc:4d:2a:ff root@nodeB
The key's randomart image is:
+--[ RSA 2048]----+
| |
| . |
| . o |
| +.* . |
| ..S*o= |
| .=oB = |
| =.o o |
| .o E |
| .. |
+-----------------+

Step2. 佈署 public key
若您要從 nodeB, 以 ssh w/o passwd 進入 nodeA
請將 nodeB 的 public key, 放置於 nodeA, /UserAccount/.ssh/authorized_keys

[root@nodeA ~] # cat /root/.ssh/authorized_keys
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAwLmrP46JukEdUjHhK1tsyhHgTtKd65nlxHjSdVDBtXLvYukYMij3qX1qLOG9x2gQBWt2WBOyacULi5HajexMuU9aQTTTYdHXbA+Vyn/tO26
NkGVXiQm0LFZpRBqQBrhUcvTeOD0yHmMC9iqbEUBpyQXA8XELZNoKrYGOIKiPHpfduaeYfnt7nZ7T7Nou/MoFbpuvXmfpeVg6S01gPMOKXpkgFrigwtcw/W59d7ia5I6rhPEIrkHQjGGN/Q
N6NCifvtkIeWt+UY2lz1f+hhmvtKC6esiY3y7U3U9iLrSHBLHh+Tm5KLcKhJw1qgnDu8vsj7uL5DMg6kk98CZKuKi+== root@nodeB

Step3. 測試連線

[root@nodeB ~] # ssh -2 nodeA
Last login: Thu Apr 22 12:33:07 2010 from nodeB
[root@nodeA ~] #


沒有留言:

張貼留言