《如何在主機之間建立SSH信任關(guān)系?》要點:
本文介紹了如何在主機之間建立SSH信任關(guān)系?,希望對您有用。如果有疑問,可以聯(lián)系我們。
服務(wù)器之間建立信任關(guān)系,對于監(jiān)控服務(wù)器管理很必要.這里介紹ssh的無密碼登陸.
本機ip:192.168.1.6
[root@codfei ~]# ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
/root/.ssh/id_rsa already exists.
Overwrite (y/n)? y (因為我是第2次建立關(guān)系所以此處覆蓋原來的文件)
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:
04:37:13:2a:4b:10:af:c1:2b:03:3f:6b:27:ce:b9:62 root@codfei
[root@codfei ~]# cd .ssh/
[root@codfei .ssh]# ll
-rw——- 1 root root 883 Apr 25 17:51 id_rsa
-rw-r–r– 1 root root 221 Apr 25 17:51 id_rsa.pub
-rw-r–r– 1 root root 442 Apr 25 17:37 known_hosts
id_rsa是密鑰文件,id_rsa.pub是公鑰文件.
[root@codfei .ssh]# scp id_rsa.pub192.168.1.4:/root/.ssh/192.168.1.6
root@192.168.1.4’s password:
id_rsa.pub 100% 221 0.2KB/s 00:00
這里把公鑰文件取名為本機的ip地址就是為了以后和更多的機器建立信任關(guān)系不發(fā)生混淆.
現(xiàn)在登陸到192.168.1.4機器
[root@codfei ~]# cd .ssh/
[root@codfei .ssh]# cat 192.168.1.6 >> authorized_keys
然后回到192.168.1.6機器直接
[root@codfei .ssh]# ssh 192.168.1.4
Last login: Wed Aug 8 12:14:42 2007 from 192.168.1.6
這樣就可以了,里面偶爾涉及到權(quán)限問題.一般./ssh文件夾是755 authorized_keys為600或者644
博文出處:http://blog.chinaunix.net/space.php?uid=7176679&do=blog&id=2067903
轉(zhuǎn)載請注明本頁網(wǎng)址:
http://www.snjht.com/jiaocheng/4689.html