gcloud:通过 ssh 连接到服务器时权限被拒绝(public 密钥)
gcloud: permission denied (public key) when ssh-ing to server
我正在尝试为 gcloud 实例设置一个新的 ssh 密钥。我按照这里的说明逐字 (https://cloud.google.com/compute/docs/instances/adding-removing-ssh-keys),生成一个新密钥,将 public rsa-ssh 密钥和我的用户名放在 Google 云中元数据选项卡的 SSH 密钥部分平台界面,并使用 chmod 为我的 public 和私钥设置适当的权限。
尝试使用 -vvv verbose 标志进行 ss 时,出现如下错误:
...
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /Users/erickofman/.ssh/salsadb
debug3: send_pubkey_test
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
debug2: we did not send a packet, disable method
debug1: No more authentication methods to try.
Permission denied (publickey).
我(和同事)确保我的 public 密钥包含在服务器 .ssh 文件夹的 authorized_keys 文件中。考虑到也许有些东西已经过时了,我也尝试使用 service sshd restart
重新启动 ssh 服务器,但无济于事。
我也尝试使用 gcloud 工具设置 ssh,结果相同。
据我所知,我的站点 role/permissions 是正确的。
这是服务器端日志的样子:
admin@awesome-website:~$ tail /var/log/auth.log
Nov 15 20:40:16 awesome-website sshd[18846]: input_userauth_request: invalid user ekofman [preauth]
Nov 15 20:40:17 awesome-website sshd[18846]: Connection closed by 10.100.100.10 port 90001 [preauth]
Nov 15 20:41:17 awesome-website sshd[18848]: Connection closed by 200.200.20.20 port 90002 [preauth]
我为此苦苦思索了一段时间,非常感谢任何帮助!
每个 this 请确保您在 您的用户的 目录中。ssh/authorized_keys。
您还需要确保您的 .ssh 目录和 authorized_keys 设置了正确的权限。 (分别为 700 和 600)。
sudo chmod 700 ~/.ssh
sudo chmod 600 ~/.ssh/authorized_keys
Whelp,事实证明,新的 ssh 密钥不会被合并,除非执行完整的实例重启。 不是 ssh 服务器重启,而是整个实例重启(停止 gcloud 实例,然后启动 gcloud 实例)。文档里没说,知道了以后参考。
我正在尝试为 gcloud 实例设置一个新的 ssh 密钥。我按照这里的说明逐字 (https://cloud.google.com/compute/docs/instances/adding-removing-ssh-keys),生成一个新密钥,将 public rsa-ssh 密钥和我的用户名放在 Google 云中元数据选项卡的 SSH 密钥部分平台界面,并使用 chmod 为我的 public 和私钥设置适当的权限。
尝试使用 -vvv verbose 标志进行 ss 时,出现如下错误:
...
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /Users/erickofman/.ssh/salsadb
debug3: send_pubkey_test
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
debug2: we did not send a packet, disable method
debug1: No more authentication methods to try.
Permission denied (publickey).
我(和同事)确保我的 public 密钥包含在服务器 .ssh 文件夹的 authorized_keys 文件中。考虑到也许有些东西已经过时了,我也尝试使用 service sshd restart
重新启动 ssh 服务器,但无济于事。
我也尝试使用 gcloud 工具设置 ssh,结果相同。
据我所知,我的站点 role/permissions 是正确的。
这是服务器端日志的样子:
admin@awesome-website:~$ tail /var/log/auth.log
Nov 15 20:40:16 awesome-website sshd[18846]: input_userauth_request: invalid user ekofman [preauth]
Nov 15 20:40:17 awesome-website sshd[18846]: Connection closed by 10.100.100.10 port 90001 [preauth]
Nov 15 20:41:17 awesome-website sshd[18848]: Connection closed by 200.200.20.20 port 90002 [preauth]
我为此苦苦思索了一段时间,非常感谢任何帮助!
每个 this 请确保您在 您的用户的 目录中。ssh/authorized_keys。
您还需要确保您的 .ssh 目录和 authorized_keys 设置了正确的权限。 (分别为 700 和 600)。
sudo chmod 700 ~/.ssh
sudo chmod 600 ~/.ssh/authorized_keys
Whelp,事实证明,新的 ssh 密钥不会被合并,除非执行完整的实例重启。 不是 ssh 服务器重启,而是整个实例重启(停止 gcloud 实例,然后启动 gcloud 实例)。文档里没说,知道了以后参考。