[SSH][Putty] Permission denied (publickey,gssapi-with-mic). When Trying SSH Public Key Authentication Login

Tadashi Shigeoka ·  Wed, February 15, 2012

When trying to login to another server using SSH public key authentication from a server I had logged into via SSH with Putty, I encountered an error.

■ Error Content

$ ssh example.com
Permission denied (publickey,gssapi-with-mic). 

The cause was that the Pageant authentication key forwarding settings weren’t configured properly.

認証鍵の転送 / Authentication Key Forwarding

Pageant は ssh-agent と同じく、認証鍵の転送機能を持っています。これを利用すれば、たとえログイン先のサーバーに認証鍵がなくても、ローカルにある認証鍵を使用してログイン先からさらに別のサーバーに SSH 接続を確立できます。サーバーに秘密鍵を保存する必要が無いため、秘密鍵の流出の危険を大幅に削減できます。

「Like ssh-agent, Pageant has an authentication key forwarding feature. Using this, even if there are no authentication keys on the destination server, you can use local authentication keys to establish SSH connections from the login destination to other servers. Since there’s no need to store private keys on servers, this significantly reduces the risk of private key leakage.」

Pageant による認証鍵の転送は以下の手順で利用できます。 「Authentication key forwarding with Pageant can be used with the following steps:」

  1. Pageant を起動し、必要な認証鍵を登録する。 「1. Start Pageant and register the necessary authentication keys.」

  2. PuTTY を起動する。 「2. Start PuTTY.」

  3. 普通に SSH ログインするのですが、その際に [接続]-[SSH]-[認証] の「エージェントフォワーディングを認める」にチェックを入れておきます。もしくは、起動時に “-A” オプションを指定する方法もあります。 「3. Login via SSH normally, but check ‘Allow agent forwarding’ in [Connection]-[SSH]-[Auth]. Alternatively, you can specify the ‘-A’ option at startup.」

  4. ログイン先で、さらに “ssh <ユーザー名>@<ホスト名>” などとしてさらに別のホストにログインします。 「4. From the login destination, further login to another host using ‘ssh @’ etc.」

  5. Pageant に必要な認証鍵が登録されていれば、正常にログインできるはずです。 「5. If the necessary authentication keys are registered in Pageant, you should be able to login normally.」

なお、Pageant で認証鍵の転送機能を利用するためには、ログイン先の SSH サーバーが OpenSSH でなければなりません。本家 SSH は OpenSSH とは別のプロトコルを使用しており、そちらは Pageant ではサポートされていません。 「Note that to use Pageant’s authentication key forwarding feature, the destination SSH server must be OpenSSH. The original SSH uses a different protocol from OpenSSH, which is not supported by Pageant.」

・Reference: Pageant でパスフレーズの入力を省く - WebOS Goodies

In my case, I had registered the authentication keys in Pageant, but I hadn’t checked “Allow agent forwarding”, so the authentication key forwarding wasn’t working properly.

That’s all from the Gemba regarding SSH agent forwarding troubleshooting.