ansible 学习难点攻克
昨天进行了ansible的学习。使用服务器已经由同事安装完成。
在执行
ssh-copy-id wang@XXX.xx.xxx时报错。
Jenkins:~ jenkins$ ssh-copy-id root@xxxx
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/Users/jenkins
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filt
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are pro
Permission denied (publickey).
错误原因:ssh在没有密钥登录的情况下,禁用了密码登录,故出现如上错误。
解决办法:
登录服务器,将/etc/ssh/sshd_config文件中的PasswordAuthentication no 改为PasswordAuthentication yes
重启sshd服务:/etc/init.d/ssh restart
再次执行:
Jenkins:~ jenkins$ ssh-copy-id wang@xxxx
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/Users/jenkins/.ssh/id_rsa.pub"
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
wang@119.23.241.8's password:
输入密码即成功。
输入ssh wang@xxxxx 则登录我的服务器成功