ssh實現無密碼登陸

方法一:

Connection to 192.168.2.100,192.168.2.101

找到/root/.ssh下,刪除所有文件,若無.ssh文件夾。相互ssh初始化後,會生成.ssh目錄。

[root@localhost ~]# ls /root/.ssh

known_hosts

[root@localhost ~]# cd /root/.ssh

[root@localhost .ssh]# rm -rf *                     #刪除所有文件

[root@localhost .ssh]# ssh-keygen

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:

cd:f0:ba:08:0b:31:a6:a7:4f:15:3a:11:24:f4:63:38 [email protected]

[root@localhost .ssh]# 

[root@localhost .ssh]# ll

total 8

-rw------- 1 root root 1675 Jun 22 18:43 id_rsa

-rw-r--r-- 1 root root  408 Jun 22 18:43 id_rsa.pub     #生成公鑰和私鑰

[root@localhost .ssh]# scp id_rsa.pub [email protected]:/root/.ssh/authorized_keys

The authenticity of host '192.168.2.101 (192.168.2.101)' can't be established.

RSA key fingerprint is 37:1a:c4:32:79:9d:0f:4d:85:94:4e:4b:59:39:19:ea.

Are you sure you want to continue connecting (yes/no)? yes          

Warning: Permanently added '192.168.2.101' (RSA) to the list of known hosts.

[email protected]'s password: 

id_rsa.pub                                   100%  408     0.4KB/s   00:00

                           #上傳公鑰到客戶端.ssh下     

[root@localhost .ssh]# ssh 192.168.2.101

Last login: Sat Jun 21 02:21:49 2014 from 192.168.2.100

Welcome to Dengmin's lab! It's Sat Jun 21 02:23:57 CST 2014       #實現無密碼登陸,反之亦然


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章