close

情況:A SSH 到B不要輸入帳號密碼
先在B上把/etc/ssh/sshd_config中
PasswordAuthentication no
#service sshd restart

在A上產生一對key(Public & Private)
#ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/home/MA19/.ssh/id_rsa): 
Enter passphrase (empty for no passphrase): <輸入密碼>
Enter same passphrase again: <輸入密碼>
Your identification has been saved in /home/MA19/.ssh/id_rsa.
Your public key has been saved in /home/MA19/.ssh/id_rsa.pub.
The key fingerprint is:
fd:cf:02:69:fb:a1:e7:d7:f0:af:94:75:49:0c:a8:1e MA19@19
The key's randomart image is:
+--[ RSA 2048]----+
| .. |
| . o |
| . o |
| E . .|
| S o. .o|
| .+. .o.|
| . oo o+ |
| ..o=. o|
| .+oo+.o|
+-----------------+

在B上隨便找一個user的home資料夾(假設user1)
#cd /home/user1/.ssh
#vi authorized_keys
( 把A的public key(id_rsa.pub)內容全部貼上
注意,不要斷行)

以後在A的電腦上只要
#ssh user1@B的ip 就可以登入了

 

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 slinbody 的頭像
    slinbody

    495884965

    slinbody 發表在 痞客邦 留言(0) 人氣()