ssh-copy-id输入密码后Permission denied, please try again.

ssh-copy-id输入密码后Permission denied, please try again.

Ansible使用ping模块是通过ssh进行连接。
(已经提前在主机列表文件添加相应主机ip)
使用命令

ansible all -m ping -k

出错,实际上必须要先ssh连接过一次并且记入缓存
这个ssh验证过程可以用以下命令:

ssh-keygen
ssh-copy-id 192.168.30.101(指定ip)

由于使用的两台机子一台是自己开设的虚拟机,另外一台在云上,通过虚拟机实际ssh-copy-id会出现以下错误Permission denied, please try again.
复制ssh-copy-id出错
解决方案:在两台机子上修改ssh配置文件

vim /etc/ssh/sshd_config

编辑 PermitRootLogin 和 PasswordAuthentication 两项为yes,保存并退出

重启服务

/etc/init.d/ssh restart

重启成功

两边都操作完之后尝试下ssh连接该指定机子,可以ssh登录成功

exit退出后我们继续尝试ansible 的ping模块

我们之前的操作已经实现免密验证,这次我们直接回车不输入password试一次
成功
成功了!
上面有说错的地方请留言,交流指正~

发布了5 篇原创文章 · 获赞 1 · 访问量 2219
展开阅读全文

ssh登陆“Permission denied ”是怎么回事?

07-19

ssh登陆服务器,输入密码后却一直不能登陆进去,输出的调试信息是: ``` wangxiaoxiaodeMacBook-Air:.ssh wangxiaoxiao$ ssh -v -p 1029 xxwang@115.156.164.251 OpenSSH_6.9p1, LibreSSL 2.1.8 debug1: Reading configuration data /etc/ssh/ssh_config debug1: /etc/ssh/ssh_config line 21: Applying options for * debug1: Connecting to 115.156.164.251 [115.156.164.251] port 1029. debug1: Connection established. debug1: identity file /Users/wangxiaoxiao/.ssh/id_rsa type 1 debug1: key_load_public: No such file or directory debug1: identity file /Users/wangxiaoxiao/.ssh/id_rsa-cert type -1 debug1: key_load_public: No such file or directory debug1: identity file /Users/wangxiaoxiao/.ssh/id_dsa type -1 debug1: key_load_public: No such file or directory debug1: identity file /Users/wangxiaoxiao/.ssh/id_dsa-cert type -1 debug1: key_load_public: No such file or directory debug1: identity file /Users/wangxiaoxiao/.ssh/id_ecdsa type -1 debug1: key_load_public: No such file or directory debug1: identity file /Users/wangxiaoxiao/.ssh/id_ecdsa-cert type -1 debug1: key_load_public: No such file or directory debug1: identity file /Users/wangxiaoxiao/.ssh/id_ed25519 type -1 debug1: key_load_public: No such file or directory debug1: identity file /Users/wangxiaoxiao/.ssh/id_ed25519-cert type -1 debug1: Enabling compatibility mode for protocol 2.0 debug1: Local version string SSH-2.0-OpenSSH_6.9 debug1: Remote protocol version 2.0, remote software version OpenSSH_6.6.1p1 Ubuntu-2ubuntu2.3 debug1: match: OpenSSH_6.6.1p1 Ubuntu-2ubuntu2.3 pat OpenSSH_6.6.1* compat 0x04000000 debug1: Authenticating to 115.156.164.251:1029 as 'xxwang' debug1: SSH2_MSG_KEXINIT sent debug1: SSH2_MSG_KEXINIT received debug1: kex: server->client chacha20-poly1305@openssh.com <implicit> none debug1: kex: client->server chacha20-poly1305@openssh.com <implicit> none debug1: expecting SSH2_MSG_KEX_ECDH_REPLY debug1: Server host key: ecdsa-sha2-nistp256 SHA256:hEan0tTVdOIgIhYZnv9cee++XRQXxts3RWehu5+cDis debug1: Host '[115.156.164.251]:1029' is known and matches the ECDSA host key. debug1: Found key in /Users/wangxiaoxiao/.ssh/known_hosts:1 debug1: SSH2_MSG_NEWKEYS sent debug1: expecting SSH2_MSG_NEWKEYS debug1: SSH2_MSG_NEWKEYS received debug1: SSH2_MSG_SERVICE_REQUEST sent debug1: SSH2_MSG_SERVICE_ACCEPT received debug1: Authentications that can continue: publickey,password debug1: Next authentication method: publickey debug1: Offering RSA public key: /Users/wangxiaoxiao/.ssh/id_rsa debug1: Authentications that can continue: publickey,password debug1: Trying private key: /Users/wangxiaoxiao/.ssh/id_dsa debug1: Trying private key: /Users/wangxiaoxiao/.ssh/id_ecdsa debug1: Trying private key: /Users/wangxiaoxiao/.ssh/id_ed25519 debug1: Next authentication method: password xxwang@115.156.164.251's password: debug1: Authentications that can continue: publickey,password Permission denied, please try again. xxwang@115.156.164.251's password: debug1: Authentications that can continue: publickey,password Permission denied, please try again. xxwang@115.156.164.251's password: debug1: Authentications that can continue: publickey,password debug1: No more authentication methods to try. Permission denied (publickey,password).``` ``` 然后我谷歌了一下,按照网上的方法,把.ssh删了,再重新ssh-keygen重新生成,后再ssh,依然存在这个同样的问题? 问答

没有更多推荐了,返回首页

©️2019 CSDN 皮肤主题: 大白 设计师: CSDN官方博客

分享到微信朋友圈

×

扫一扫,手机浏览