无法连接两个 Azure 虚拟机 - 权限被拒绝(public 键)

Can't connect two Azure Virtual Machines - permission denied (public key)

我正在尝试连接两个 Microsoft Azure 虚拟机。两者都在同一个虚拟网络上。当我尝试连接 ssh 时,终端 returns Permission denied(publickey)。关于为什么我会收到此错误的想法?我尝试检查我的网络 inbound/outbound 端口规则,但虚拟网络上没有防火墙。

所以我的问题不在于我的机器和 VM 之间的连接,它工作正常。我无法在两个 VM 之间使用 ssh 进行连接。

看看这个描述:

When you use an SSH client to connect to your Linux VM (which has the public key), the remote VM tests the client to make sure it possesses the private key. If the client has the private key, it's granted access to the VM.

您的 public 密钥似乎出现了问题。使用 public 密钥创建 Azure VM 时,应确保 public 密钥也在您的主目录中,例如 ~/.ssh/。这意味着您的本地计算机和 VM 都存储了 public 密钥。然后,您可以使用 public 密钥通过从本地计算机接受的权限对 Azure VM 进行 ssh。可以看到步骤How to create the VM with a public key.