SSH公開鍵権限が拒否されました(Google Cloud Platform)

SSH公開鍵権限が拒否されました(Google Cloud Platform)

Google Cloud Platform で少数の Debian サーバーを運営しています。私たちが設定した新しいサーバーでは、生成時にSSHキーを追加し、問題なくSSH経由でシステムにアクセスできました。過去1〜3ヶ月以内に作成された古いマシンにSSH経由でアクセスできません。

テストケースとして、ローカルMacを使用して新しいid_rsaキーペアを作成し、ssh-keygen公開キーをGCPに追加しました。私のIPはボックスにアクセスでき、私のユーザーはAllowUsersssh_configにあります。

$ ssh -i ~/.ssh/*KEY* *USER*@*IP* -p *PORT* -v
OpenSSH_6.9p1, LibreSSL 2.1.8
debug1: Reading configuration data /Users/me/.ssh/config
debug1: /Users/me/.ssh/config line ****: Applying options for ****IP****
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line ****: Applying options for *
debug1: /etc/ssh/ssh_config line ****: Applying options for *
debug1: Connecting to ****IP**** [****IP****] port ****PORT****.
debug1: Connection established.
debug1: identity file /Users/me/.ssh/gcp type 1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/me/.ssh/gcp-cert type -1
debug1: identity file /Users/me/.ssh/gcp type 1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/me/.ssh/gcp-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.9
debug1: Remote protocol version 2.0, remote software version OpenSSH_6.7p1
debug1: match: OpenSSH_6.7p1 pat OpenSSH* compat 0x04000000
debug1: Authenticating to ****IP****:****PORT**** as '****USERNAME****'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client [email protected] <implicit> none
debug1: kex: client->server [email protected] <implicit> none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: xxx
debug1: Host '[****IP****]:****PORT****' is known and matches the ECDSA host key.
debug1: Found key in /Users/me/.ssh/known_hosts:1
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
********************************************************************
*                                                                  *
* This system is for the use of authorized users only.  Usage of   *
* this system may be monitored and recorded by system personnel.   *
*                                                                  *
* Anyone using this system expressly consents to such monitoring   *
* and is advised that if such monitoring reveals possible          *
* evidence of criminal activity, system personnel may provide the  *
* evidence from such monitoring to law enforcement officials.      *
*                                                                  *
********************************************************************
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /Users/me/.ssh/gcp
debug1: Authentications that can continue: publickey
debug1: Offering RSA public key: /Users/me/.ssh/gcp
debug1: Authentications that can continue: publickey
debug1: No more authentication methods to try.
Permission denied (publickey).  

私のキーが見つかったにもかかわらず、私のローカルクライアントは接続後に認証を試みないようです。これが私の公開鍵をサーバーに正しく追加しないGCPの問題なのか、それとも私のローカルコンピュータが間違っているのかはわかりません。

Googleは過去数ヶ月間のキーの処理方法を変更したようです(メタデータでSSHキーを管理する)しかし、すべてが正しいようですが、接続できません。

ベストアンサー1

調査の結果、Google Cloud Platform で Debian システムに SSH キーを適用する際に問題があることがわかりました。プロジェクトレベルでキー全体を追加するか、Debianボックスに手動でユーザーを追加し、各ユーザーのAuthorized_keysにキーを手動で追加することで機能します。インスタンスレベルで追加しても効果はありません。 Googleにバグを報告します。

おすすめ記事