讓centos45的root用戶ssh登入redhat9 時不需要手動輸入密碼
在centos45下的設置:
[root@centos45 ~]# cd [root@centos45 ~]# ssh-keygen -d 運行這個才會生成.ssh這個目錄 Generating public/private dsa key pair. Enter file in which to save the key (/root/.ssh/id_dsa): Created directory ‘/root/.ssh‘. Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /root/.ssh/id_dsa. Your public key has been saved in /root/.ssh/id_dsa.pub. The key fingerprint is: 1f:24:66:48:d2:4b:3c:ee:02:a8:49:d3:d5:76:8f:e4 root@centos45 [root@centos45 ~]# cd .ssh [root@centos45 .ssh]# ls id_dsa id_dsa.pub
[root@centos45 .ssh]# scp id_dsa.pub 10.10.7.247:/root/.ssh/centos45_authorized_keys2 其實應該用主機名redhat9,但我沒在host中添加只好用IP代替
The authenticity of host ‘10.10.7.247 (10.10.7.247)‘ can‘t be established. RSA key fingerprint is 20:10:bd:9a:5f:56:36:1c:25:6a:dc:c8:8b:33:15:9f. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added ‘10.10.7.247‘ (RSA) to the list of known hosts. root@10.10.7.247‘s password: Permission denied, please try again. root@10.10.7.247‘s password: id_dsa.pub 100% 603 0.6KB/s 00:00
|
在redhat9下的設置:
[root@redhat9 root]# cd [root@redhat9 root]# mkdir .ssh
[root@redhat9 root]# chmod 700 .ssh [root@redhat9 root]# ll -a total 80 drwxr-x--- 4 root root 4096 Jul 6 09:03 . drwxr-xr-x 20 root root 4096 Jul 6 08:47 .. -rw-r--r-- 1 root root 1126 Aug 24 1995 .Xresources -rw------- 1 root root 3505 Jun 21 10:41 .bash_history -rw-r--r-- 1 root root 24 Jun 11 2000 .bash_logout -rw-r--r-- 1 root root 234 Jul 6 2001 .bash_profile -rw-r--r-- 1 root root 176 Aug 24 1995 .bashrc -rw-r--r-- 1 root root 210 Jun 11 2000 .cshrc drwx------ 2 root root 4096 Jun 16 23:18 .gconfd drwx------ 2 root root 4096 Jul 6 09:03 .ssh -rw-r--r-- 1 root root 196 Jul 11 2000 .tcshrc -rw------- 1 root root 4496 Jun 21 10:12 .viminfo -rw-r--r-- 1 root root 1157 Jun 16 23:45 anaconda-ks.cfg -rw-r--r-- 1 root root 14041 Jun 16 23:42 install.log -rw-r--r-- 1 root root 3534 Jun 16 23:42 install.log.syslog -rw-r--r-- 1 root root 1671 Jun 17 11:09 root.txt [root@redhat9 root]# cd .ssh
[root@redhat9 .ssh]# ll total 4 -rw-r--r-- 1 root root 603 Jul 6 09:14 centos45_authorized_keys 2
[root@redhat9 .ssh]# cat centos45_authorized_keys2 >> authorized_keys2 [root@redhat9 .ssh]# ll total 8 -rw-r--r-- 1 root root 603 Jul 6 09:15 authorized_keys2 -rw-r--r-- 1 root root 603 Jul 6 09:14 centos45_authorized_keys2
|
測試結(jié)果:
[root@centos45 .ssh]# ssh 10.10.7.247 Last login: Fri Jul 6 08:50:59 2007 from 10.10.7.245 [root@redhat9 root]# ls anaconda-ks.cfg install.log install.log.syslog root.txt [root@redhat9 root]# exit logout Connection to 10.10.7.247 closed. |
參考資料:
|