创建一个SSH密钥 [root@oplinux ~]# ssh-keygen -t rsa -P '' -f ~/.ssh/id_rsa Generating public/private rsa key pair. /root/.ssh/id_rsa already exists. Overwrite (y/n)? yes 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: f8:d4:aa:99:55:23:b3:c9:2e:81:ea:03:69:e9:d7:c9 root@oplinux.hehaibo.com [root@oplinux ~]# cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys [root@oplinux ~]# ssh localhost @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ WARNING: UNPROTECTED PRIVATE KEY FILE! @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ #提示不能通过ssh localhost直接登录 权限有问题 把权限降到0600就ok Permissions 0666 for '/root/.ssh/id_rsa' are too open. It is recommended that your private key files are NOT accessible by others. This private key will be ignored. bad permissions: ignore key: /root/.ssh/id_rsa Enter passphrase for key '/root/.ssh/id_rsa': Last login: Tue Mar 6 19:07:51 2012 from 192.168.91.1 #解决办法 执行如下命令 [root@oplinux ~]# chmod 0600 ~/.ssh/id_rsa #登陆成功 [root@oplinux ~]# ssh localhost Last login: Tue Mar 6 19:10:52 2012 from oplinux.hehaibo.com [root@oplinux ~]#