0
0

Putty使用公钥认证时,报错:Disconnected: No supported authentication methods available(server sent:public key) 问题的解决

qingran 发表于 2014年01月04日 17:28 | Hits: 48898
Tag: Security | Software | putty | ssh

Putty使用公钥认证时,按照常规方法设置,一直报错:Disconnected: No supported authentication methods available (server sent:public key)。

如截图:

putty-error

 

找了半天没找到问题出在哪里,sshd的设置一切正常。这个做过多次居然也能错????

 

最后发现原来是 ~/.ssh/authorized_keys 文件的内容有问题,putty生成的pub文件的格式如下:


---- BEGIN SSH2 PUBLIC KEY ----
Comment: "rsa-key"
AAAAB3NzaC1yc2EAAAABJQAAAQEAvifBFJzxK0PGJVNV9ZdDGOYWvytwnFDKoaZv
Djdt7rEK+zeFzR6eU7ERhOjMPb7GfoFU/1JPwXqSN2p57T4xdtR/Qi9/XAhmQ9SY
XnfA1yNOhHXoQuoCEjOmIbOo+NmZCoKPeBob7fXV8Ar7MmJ0vUpZ+79Usm9lsvQF
zEfI/Q1NuaVoOb7s6CFyj9WcmX7Yzc3cXpIHeFzLfLTFFROohw==
---- END SSH2 PUBLIC KEY ----

而原来设置的都是在一行的格式,所以openssh不支持putty生成的此格式,需要把这些合并成一行即可:

ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAQEAvifBFJzxK0PGJVNV9ZdDGOYWvytwnFDKoaZvDjdt7rEK+zeFzR6eU7ERhOjMPb7GfoFU/1JPwXqSN2p57T4xdtR/Qi9/XAhmQ9SYXnfA1yNOhHXoQuoCEjOmIbOo+NmZCoKPeBob7fXV8Ar7MmJ0vUpZ+79Usm9lsvQFzEfI/1NuaVoOb7s6CFyj9WcmX7Yzc3cXpIHeFzLfLTFFROohw== rsa-key

原文链接: http://www.qingran.net/2014/01/putty%e4%bd%bf%e7%94%a8%e5%85%ac%e9%92%a5%e8%ae%a4%e8%af%81%e6%97%b6%ef%bc%8c%e6%8a%a5%e9%94%99%ef%bc%9adisconnected-supported-authentication-methods-availableserver-sentpublic-key-%e9%97%ae/

0     0

评价列表(0)