问题描述
在windows下,公钥私钥设置好,公钥放在服务器之后,ssh连接仍然需要密码。调试方法可以使用 ssh -vvv user@host
这样的命令查看信息。下面是最后一些关节内容,我这里解决的是如下信息的问题,关键在如下倒数第二行, we did not send a packet, disable method
, 公钥方法失败之后就开始输入密码了。
debug3: authmethod_lookup publickey
debug3: remaining preferred: keyboard-interactive,password
debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Offering public key: balabalaxxxxxxx(这里我做了修改,显示的是密钥文件内容,当然我在ssh的config文件中指定了密钥路径,因为我修改了ssh-keygen生成密钥的文件名称,显示了密钥说明它找到了密钥文件)
debug3: send packet: type 50
debug2: we sent a publickey packet, wait for reply
debug3: receive packet: type 51
debug1: Authentications that can continue: publickey,password
debug2: we did not send a packet, disable method
debug3: authmethod_lookup password
问题解决
如上问题大概率是因为密钥文件权限的问题,在windows中修改权限不能直接 chmod ,所以比较难搞。参考这里可以解决。