linux ssh无密码登录
上一篇 /
下一篇 2012-09-08 17:20:11
/ 个人分类:运维相关
1、环境
192.168.0.5 登录机
192.168.0.10 被登录机
2、执行步骤
(1)在192.168.0.5上执行
#ssh-keygen -t rsa 一路回车
在~/root/.ssh/目录下生一对公钥和私钥id_rsa id_rsa.pub
(2)把公钥id_rsa.pub拷贝到远程登录机192.168.0.10上之后,在192.168.0.5执行以下命令
# ssh-copy-id -i /root/.ssh/id_rsa.pub root@192.168.0.10
21
Warning: Permanently added '192.168.0.10 (RSA) to the list of known hosts.
root@192.168.0.10's password:
Now try logging into the machine, with "ssh 'root@192.168.0.10'", and check in:
.ssh/authorized_keys
to make sure we haven't added extra keys that you weren't expecting. 成功!
3、配置验证
在192.168.0.5上执行
# ssh 192.168.0.10 //不用输入密码就能直接ssh成功
4、遇到的错误及解决方法
# ssh-copy-id remote-machine
公钥,私钥已经生成,执行上述命令完毕出现如下错误:
/usr/bin/ssh-copy-id: ERROR: No identities found
# 是因为缺少公钥路径,通过 -i 加上即可:
# ssh-copy-id -i ~/root/.ssh/id_dsa.pub user@remote_ip
收藏
举报
TAG: