我正在尝试连接到 Google Cloud 上的虚拟机。我创建了一个用于 SSH 的公钥并将该密钥添加到云实例。我已SSH_AUTH_SOCK
设置为gpg-agent
.
~/.gnupg/gpg-agent.conf
default-cache-ttl 600
max-cache-ttl 7200
enable-ssh-support
pinentry-program /usr/local/MacGPG2/libexec/pinentry-mac.app/Contents/MacOS/pinentry-mac
~/.zprofile
...
export SSH_AUTH_SOCK=$(gpgconf --list-dirs agent-ssh-socket)
gpgconf --launch gpg-agent
一切似乎都正常工作:
% ssh-add -L
ssh-rsa AAAAB3NzaC1yc2EA... (none)
但是,当我尝试实际连接到虚拟机时...
debug1: Offering public key: (none) RSA SHA256:[REDACTED] agent
debug3: send packet: type 50
debug2: we sent a publickey packet, wait for reply
debug3: receive packet: type 51
debug1: Authentications that can continue: publickey
debug1: Trying private key: /Users/alice/.ssh/id_rsa
debug3: no such identity: /Users/alice/.ssh/id_rsa: No such file or directory
debug1: Trying private key: /Users/alice/.ssh/id_dsa
debug3: no such identity: /Users/alice/.ssh/id_dsa: No such file or directory
debug1: Trying private key: /Users/alice/.ssh/id_ecdsa
debug3: no such identity: /Users/alice/.ssh/id_ecdsa: No such file or directory
debug1: Trying private key: /Users/alice/.ssh/id_ed25519
debug3: no such identity: /Users/alice/.ssh/id_ed25519: No such file or directory
debug1: Trying private key: /Users/alice/.ssh/id_xmss
debug3: no such identity: /Users/alice/.ssh/id_xmss: No such file or directory
debug2: we did not send a packet, disable method
debug1: No more authentication methods to try.
[email protected]: Permission denied (publickey).
%
所以,显然我需要
~/.ssh/authorized_keys
在服务器端添加公钥。我最初是通过基于 Web 的管理控制台在标有“ SSH 密钥”的部分下添加密钥的。我仍然不知道为什么这似乎不起作用。