SSH公钥login失败,没有模式

(以前张贴在错误的计算器)

我正在运行一系列Ubuntu 14.04.1(sun,hyperion,…)的服务器,所有这些服务器都使用rsync的公钥(OpenSSH_6.6.1,OpenSSL 1.0.1f 2014年1月6日,在所有机器上),没有任何问题。 几乎全部…

一个连接失败,没有任何configuration或密钥的变化。 然后我会尝试重新添encryption钥,检查ECDSA,重新启动/重新启动ssh,然后再次运行。 或者它不。 在这种情况下,我只需要等待一段时间(1小时到3个月)。 这一次,它解决了这个问题 – 一段时间。

ssh -vvv diff的相关部分:

成功的连接

debug1: Host 'hyperion.internal' is known and matches the ECDSA host key. debug1: Found key in /home/bar/.ssh/known_hosts:20 debug1: ssh_ecdsa_verify: signature correct debug2: kex_derive_keys debug2: set_newkeys: mode 1 debug1: SSH2_MSG_NEWKEYS sent debug1: expecting SSH2_MSG_NEWKEYS debug2: set_newkeys: mode 0 debug1: SSH2_MSG_NEWKEYS received debug1: Roaming not allowed by server debug1: SSH2_MSG_SERVICE_REQUEST sent debug2: service_accept: ssh-userauth debug1: SSH2_MSG_SERVICE_ACCEPT received debug2: key: /home/bar/.ssh/id_rsa (0x7f..), debug2: key: /home/bar/.ssh/id_dsa ((nil)), debug2: key: /home/bar/.ssh/id_ecdsa ((nil)), debug2: key: /home/bar/.ssh/id_ed25519 ((nil)), debug1: Authentications that can continue: publickey,password debug3: start over, passed a different list publickey,password debug3: preferred gssapi-keyex,gssapi-with-mic,publickey,keyboard-interactive,password debug3: authmethod_lookup publickey debug3: remaining preferred: keyboard-interactive,password debug3: authmethod_is_enabled publickey debug1: Next authentication method: publickey debug1: Offering RSA public key: /home/bar/.ssh/id_rsa debug3: send_pubkey_test debug2: we sent a publickey packet, wait for reply debug1: Server accepts key: pkalg ssh-rsa blen 279 debug2: input_userauth_pk_ok: fp 95:... debug3: sign_and_send_pubkey: RSA 95:... debug1: key_parse_private2: missing begin marker debug1: read PEM private key done: type RSA debug1: Authentication succeeded (publickey). Authenticated to hyperion.internal ([172.16.0.10]:22). 

连接失败

 debug1: Host 'hyperion.internal' is known and matches the ECDSA host key. debug1: Found key in /home/bar/.ssh/known_hosts:20 debug1: ssh_ecdsa_verify: signature correct debug2: kex_derive_keys debug2: set_newkeys: mode 1 debug1: SSH2_MSG_NEWKEYS sent debug1: expecting SSH2_MSG_NEWKEYS debug2: set_newkeys: mode 0 debug1: SSH2_MSG_NEWKEYS received debug1: Roaming not allowed by server debug1: SSH2_MSG_SERVICE_REQUEST sent debug2: service_accept: ssh-userauth debug1: SSH2_MSG_SERVICE_ACCEPT received debug2: key: /home/bar/.ssh/id_rsa (0x7f..), debug2: key: /home/bar/.ssh/id_dsa ((nil)), debug2: key: /home/bar/.ssh/id_ecdsa ((nil)), debug2: key: /home/bar/.ssh/id_ed25519 ((nil)), debug1: Authentications that can continue: publickey,password debug3: start over, passed a different list publickey,password debug3: preferred gssapi-keyex,gssapi-with-mic,publickey,keyboard-interactive,password debug3: authmethod_lookup publickey debug3: remaining preferred: keyboard-interactive,password debug3: authmethod_is_enabled publickey debug1: Next authentication method: publickey debug1: Offering RSA public key: /home/bar/.ssh/id_rsa debug3: send_pubkey_test debug2: we sent a publickey packet, wait for reply debug1: Authentications that can continue: publickey,password debug1: Trying private key: /home/bar/.ssh/id_dsa debug3: no such identity: /home/bar/.ssh/id_dsa: No such file or directory debug1: Trying private key: /home/bar/.ssh/id_ecdsa debug3: no such identity: /home/bar/.ssh/id_ecdsa: No such file or directory debug1: Trying private key: /home/bar/.ssh/id_ed25519 debug3: no such identity: /home/bar/.ssh/id_ed25519: No such file or directory debug2: we did not send a packet, disable method debug3: authmethod_lookup password debug3: remaining preferred: ,password debug3: authmethod_is_enabled password debug1: Next authentication method: password 

我已经检查了几次:

  • 所有机器上的.ssh /和id_rsa权限
  • 我正在使用正确的键
  • ssh-copy-id -i /home/bar/.ssh/id_rsa [email protected]将正确的密钥复制到正确的authorized_hosts文件

什么没有真正帮助,但添加到vodoo / heisenbug效果:

  • 重新启动机器
  • 重新启动ssh服务
  • 摆弄全球ssh选项

我在pastebin上粘贴了一些日志信息的完整日志: 日志墙

问题已经解决,完全不是ssh相关的:

hyperion.internal有一个encryption的家庭,所以当它没有挂载到/home/europe时,键盘查找失败。

事后看来相当明显,但是当观察机器上的日志(当然是login的时候),这就解释了heisenbug的效果,

希望这至less可以帮助别人。

 debug1: Offering RSA public key: /home/bar/.ssh/id_rsa debug3: send_pubkey_test debug2: we sent a publickey packet, wait for reply debug1: Authentications that can continue: publickey,password 

这表示服务器不接受您的私钥。 不幸的是,服务器没有提供关于为什么不接受密钥的更多细节的客户端,所以你真的需要在服务器上解决这个问题。

我将首先检查服务器上/var/log中的系统/var/log ,了解sshd发送的任何消息,指出拒绝authentication的原因。

如果您在远程服务器上拥有root访问权限,则可以运行sshd的debugging实例,然后使用客户端连接到该实例。 在远程服务器上,成为root并运行/path/to/sshd -d -p 2222 。 这将启动一个监听端口2222的sshd实例。它将接受一个连接,并将打印debugging信息到您的terminal。

然后,在客户端上,像通常一样运行ssh ,但是包括-p 2222连接到正确的端口。 如果login失败,请检查服务器打印的debugging输出。

对我来说,这是一个涉及到Home目录的权限问题。 目标服务器上主目录的权限设置为775.从我发现的主目录权限必须设置为755或更less。 这将其设置为除主目录的所有者之外的任何用户都不被允许具有写入权限的位置。

它看起来像一个服务器问题:

 debug1: Offering RSA public key: /home/bar/.ssh/id_rsa debug3: send_pubkey_test debug2: we sent a publickey packet, wait for reply debug1: Authentications that can continue: publickey,password 

服务器似乎没有在这里发送答复。 我会尝试在服务器端启动最多11个debugging,并看看它在抱怨什么。

公钥包发送失败后等待多长时间? 如果我

将根创build的文件(不仅仅是chmod)复制回原来的用户帐户。 您也可以尝试使用Userify进行testing,看看它是否有效,并且您拥有没有错误的公钥。

由于与多个计算机名称相关的MAC地址相同,因此我经常遇到ssh问题,反之亦然。 有一些命令行选项可以用来处理这个问题。 您也可以删除或编辑您的已知主机文件,以消除这个问题。 不知道这是否有帮助,但这覆盖了我的SSH问题的90%。