无法SSH到GCE:“权限被拒绝(公钥)”


20

我通过Google Compute Engine中的Bitnami创建了一个VM。以前,我能够通过Bitnami Web界面进行ssh。我试图通过Mac上的终端ssh进行操作,但始终收到Permission denied (publickey)错误消息。然后,我删除了服务器和Mac上的所有密钥,并从bitnami下载了pem文件,并使用了-i选项进行连接,但问题仍然存在。

ssh -i bitnami-gce.pem xxx@1xx.1xx.5x.1xx -v

完整的调试信息:

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 1xx.1xx.5x.1xx [1xx.1xx.5x.1xx] port 22.
debug1: Connection established.
debug1: identity file bitnami-gce.pem type -1
debug1: identity file bitnami-gce.pem-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 Debian-4~bpo70+1
debug1: match: OpenSSH_6.6.1p1 Debian-4~bpo70+1 pat OpenSSH*
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5-etm@openssh.com none
debug1: kex: client->server aes128-ctr hmac-md5-etm@openssh.com 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 <RSA KEY>
debug1: Host '1xx.1xx.5x.1xx' is known and matches the RSA host key.
debug1: Found key in /Users/xxx/.ssh/known_hosts:1
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: bitnami-gce.pem
debug1: read PEM private key done: type RSA
debug1: Authentications that can continue: publickey
debug1: No more authentication methods to try.
Permission denied (publickey).

我无法通过SSH登录到主机。所以现在不能将任何密钥发送到服务器。如何解决呢?

编辑:我试图通过Google Web控制台进行ssh,我可以做到。谁能告诉我从任何地方ssh的确切步骤?我更喜欢简单的用户名和密码方式,该如何配置呢?


1.创建后新的SSH密钥2.加入项目的SSH密钥cloud.google.com/compute/docs/instances/...
Jirayuth醒岩

Answers:


19

在能够通过Google Web控制台进行ssh之后,我执行了以下步骤来解决此问题:

  1. 使用生成SSH密钥

    ssh-keygen

  2. 复制key.pub文件内容

  3. 将内容附加到~/.ssh/authorized_keys文件

    sudo nano ~/.ssh/authorized_keys



5

由于用户的关系,我面临着同样的情况。在Google Web上,我的用户名显示了电子邮件的第一部分。所以,我正在尝试像这样的ssh

ssh <first_part_of_gmail>@google_vm_external_ip

后来,我发现google根据您在google vm设置中放置的ssh密钥创建了一个用户。因此,首先请检查公用密钥末尾的用户,然后尝试按照以下步骤操作

ssh <user_name_at_the_end_of_public_key>@google_vm_external_ip

救我一命。谢谢。
Tran Dinh Khanh

2

有相同的问题,我第一次使用gcloud命令登录并添加到“ / etc / ssh / sshd_config”

PubkeyAcceptedKeyTypes  +ssh-dss

systemctl重新启动sshd


0

这是一个老问题,但是我今天也遇到了这个问题,并按照以下步骤进行了修复:

  1. 从本地计算机生成ssh公钥
  2. 将公钥复制到gcc虚拟机设置

然后连接。

这些步骤将指导您使用ssh连接到Mac OS终端上的gcc vm实例:https : //nabtron.com/gcc-mac-terminal/ //nabtron.com/gcc-mac-terminal/,还将解决权限被拒绝(pubilckey)的问题。

希望对您有所帮助。


By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.