SSH密钥在Ubuntu Azure VPS上停止工作

我有一个在Azure上运行的Ubuntu实例。 我已经使用它在过去的6个月左右,以升级我的新手Linuxpipe理技能。 昨天我正在configuration一个Capistrano部署到这个服务器,当我的SSH密钥突然停止工作。 在过去我已经看到Permission denied而试图ssh到框,我刚刚读我的私钥到关键代理,它再次工作。 我从来不知道为什么钥匙停止工作,但既然我可以解决它没有太多的麻烦,并不经常发生,我没有想太多。 不过,昨天我没有办法解决这个问题,从那以后,我一直在努力研究这个问题。

以下是我已经采取的步骤和我已经尝试的事情:

  • 这是我平时运行的(直到昨天为止都工作了几个月): ssh azure-southerneer
  • 我的〜/ .ssh / config中的相关条目:

     Host azure-southerneer Hostname southerneer.cloudapp.net User azureuser IdentityFile ~/.ssh/azure-wp-eric.key IdentitiesOnly yes ServerAliveInterval 300 StrictHostKeyChecking no 
  • 输出: Permission denied (publickey).
  • 如果我运行它与-v标志这里是我得到:

     OpenSSH_6.2p2, OSSLShim 0.9.8r 8 Dec 2011 OpenSSH_6.2p2, OSSLShim 0.9.8r 8 Dec 2011 debug1: Reading configuration data /Users/kirkham/.ssh/config debug1: /Users/kirkham/.ssh/config line 27: Applying options for azure-southerneer debug1: Reading configuration data /etc/ssh_config debug1: /etc/ssh_config line 20: Applying options for * debug1: /etc/ssh_config line 102: Applying options for * debug1: Connecting to southerneer.cloudapp.net [191.237.4.63] port 22. debug1: Connection established. debug1: identity file /Users/kirkham/.ssh/azure-wp-eric.key type -1 debug1: identity file /Users/kirkham/.ssh/azure-wp-eric.key-cert type -1 debug1: Enabling compatibility mode for protocol 2.0 debug1: Local version string SSH-2.0-OpenSSH_6.2 debug1: Remote protocol version 2.0, remote software version OpenSSH_6.6.1p1 Ubuntu-8 debug1: match: OpenSSH_6.6.1p1 Ubuntu-8 pat OpenSSH* debug1: SSH2_MSG_KEXINIT sent debug1: SSH2_MSG_KEXINIT received debug1: kex: server->client aes128-ctr [email protected] none debug1: kex: client->server aes128-ctr [email protected] none debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP debug1: SSH2_MSG_KEX_DH_GEX_INIT sent debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY debug1: Server host key: RSA 77:6f:e6:84:ca:09:04:83:fd:37:96:3f:d3:2a:77:a6 debug1: Host 'southerneer.cloudapp.net' is known and matches the RSA host key. debug1: Found key in /Users/kirkham/.ssh/known_hosts:78 debug1: ssh_rsa_verify: signature correct debug1: SSH2_MSG_NEWKEYS sent debug1: expecting SSH2_MSG_NEWKEYS debug1: SSH2_MSG_NEWKEYS received debug1: Roaming not allowed by server debug1: SSH2_MSG_SERVICE_REQUEST sent debug1: SSH2_MSG_SERVICE_ACCEPT received debug1: Authentications that can continue: publickey debug1: Next authentication method: publickey debug1: Trying private key: /Users/kirkham/.ssh/azure-wp-eric.key debug1: read PEM private key done: type RSA debug1: Authentications that can continue: publickey debug1: No more authentication methods to try. Permission denied (publickey). 

WTF? 它正在尝试正确的钥匙,但它只是不喜欢它?

  • 我知道服务器正在运行,因为我在那里托pipe的网站仍然运行良好。 从详细的SSH输出显然是响应,它只是不喜欢我的azure-wp-eric.key(它没有改变)。
  • 我并没有故意在服务器上的azureuser主目录或者.ssh目录下玩弄权限,所以不应该把任何东西都弄糟。
  • 我尝试过从Azurepipe理门户popup服务器,但是这并没有解决任何问题。
  • 我昨天早上在服务器上运行了sudo apt-get update ,但是在testing我的capistrano部署的时候,我能够顺利地完成ssh,这似乎没有造成问题。

在这一点上,我以我的智慧结束了检查的事情。 我显然不是很熟练地解决ssh问题,所以我慢慢地通过文章试图find我失踪的文章。 我不知道有什么方法可以有条不紊地弄清楚我做错了什么,作为一名开发人员,真的困扰我。 有什么我可以忽略吗? 还有其他的事情可以证实我是对的还是错的? 有没有其他人在Ubuntu或Azure虚拟机上遇到类似的问题? 请让我知道是否有任何进一步的细节,我可以提供帮助诊断问题。 请帮忙!

我意识到我的错误。 感谢@ kasperd帮我弄明白了。 我遵循了Azure的SSH创build说明 。 当我生成我的密钥时,我使用了这个命令

 openssl req -x509 -key ~/.ssh/id_rsa -nodes -days 365 -newkey rsa:2048 -out myCert.pem 

这会生成365天后过期的新密钥。 昨天是第365天,这意味着我的钥匙不再有效。 既然这是虚拟机的唯一关键我想我被搞砸了? 有点似乎是这样。 啊。

更新: Per @ kasperd的评论,事实上我的服务器在完成一年后停止让我SSH可能只是一个疯狂的巧合。 感谢Azure文档站点上的讨论 ,我发现通过库创build的Azure Linux虚拟机加载了Microsoft Azure Linux代理,允许pipe理员通过命令行 (即Powershell) 重置SSH 。 所以,虽然切换到Windows是一个痛苦,但我能够按照步骤重置我的虚拟机上的SSH选项。 不幸的是,我仍然无法SSH进入我的机器。 很显然,我对我的机器做了一些激进的工作,而这些工作并没有被重置选项所覆盖,但是对于那些不那么激进的用户来说,希望他们可以按照其中的一些链接来帮助他们。

  • 如何安装Azure Powershell
  • 如何通过Powershell获取关于您的虚拟机的详细信息
  • 如何在Windows(腻子)SSH
  • 如何获得腻子(和Puttygen转换密钥文件到.ppk)