无法从 OS X 登录到运行 Linux 的 Azure VM

无法从 OS X 登录到运行 Linux 的 Azure VM

我一直尝试通过 SSH 验证从 OS X 登录到 Azure 中运行 Ubuntu 的虚拟机。但是当我尝试连接到虚拟机时,我收到权限被拒绝(公钥)错误。

为了创建密钥对证书,我通过终端按照以下步骤进行操作:

openssl req -x509 -nodes -days 365 \
-newkey rsa:2048 \
-keyout example1.key \
-out example1.pem

然后我设置权限:

chmod 600 example1.key

这两个文件都在我的用户文件夹中。

在创建虚拟机期间,我上传了文件 example1.pem。

创建虚拟机后,我尝试使用以下命令进行连接:

ssh -v -i myPrivateKey.key -p 22 [email protected]

这是我得到的输出:

OpenSSH_6.2p2, OSSLShim 0.9.8r 8 Dec 2011
debug1: Reading configuration data /etc/ssh_config
debug1: /etc/ssh_config line 20: Applying options for *
debug1: Connecting to ubuntuedx.cloudapp.net [23.99.90.218] port 22.
debug1: Connection established.
debug1: identity file myPrivateKey.key type -1
debug1: identity file myPrivateKey.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_5.9p1 Debian-5ubuntu1.4
debug1: match: OpenSSH_5.9p1 Debian-5ubuntu1.4 pat OpenSSH_5*
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5 none
debug1: kex: client->server aes128-ctr hmac-md5 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 20:b6:58:2c:96:75:f8:f6:b0:25:39:85:ed:ab:7a:9d
debug1: Host 'ubuntuedx.cloudapp.net' is known and matches the RSA host key.
debug1: Found key in /Users/juanse/.ssh/known_hosts:4
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: myPrivateKey.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).

我尝试使用 VIP 而不是 VM 名称,但输出结果相同。我在网上搜索了所有信息,但还是找不到问题的解决方案。

答案1

因为没有说明,所以我必须问一下。您在创建虚拟机时添加了公钥吗?有一个步骤是上传 example1.pem,然后在安装过程中将其存储在用户的 ~/.ssh/authorized_keys 文件中。

相关内容