OpenSSH の SSH クライアントは、IdentityFile の設定順序に従わない。

OpenSSH の SSH クライアントは、IdentityFile の設定順序に従わない。

OpenSSHのSSHクライアント(OpenSSH_7.5p1、OpenSSL 1.0.2k 2017年1月26日、Git for Windows v2.11.1)がSSH互換デーモン(Apache Mina SSHD(Gerrit)に公開/秘密鍵のペアを提供する順序を指定する方法))コードレビューサービス)。私の意図は、RSAに戻る前にEd25519公開/秘密鍵ペアを使用して認証を試みることです。

ユーザーのホームディレクトリに、次の標準Ed25519とRSA公開/秘密鍵のペアがあるとします。

  • ~/.ssh/id_ed25519{,.pub}
  • ~/.ssh/id_rsa{,.pub}

ユーザーのSSH設定ファイル(〜/ .ssh / config)にある次のホストセクション:

Host foobar foobar.example.com
  Hostname foobar.example.com
  IdentityFile ~/.ssh/id_ed25519

Host *
  IdentityFile ~/.ssh/id_ed25519
  IdentityFile ~/.ssh/id_rsa

デバッグモードでSSH接続をテストする場合:

$ ssh -Tv bob@foobar
debug1: Reading configuration data ~/.ssh/config
debug1: ~/.ssh/config line 49: Applying options for foobar
debug1: ~/.ssh/config line 63: Applying options for *
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering RSA public key: ~/.ssh/id_rsa
debug1: Authentications that can continue: publickey
debug1: Offering ED25519 public key: ~/.ssh/id_ed25519
debug1: Server accepts key: pkalg ssh-ed25519 blen 51
debug1: Authentication succeeded (publickey).

OpenSSHのSSHクライアントが最初にRSA公開/秘密鍵ペアを提供することがわかります。しかし、なぜEd25519を最初に使用しないのですか?

ベストアンサー1

オプションを追加してくださいIdentitiesOnly。このオプションがない場合、SSHは最初に使用可能なデフォルトのSSHキー(id_rsa、、、id_dsa)を試みますid_ecdsa。この動作を変更するには、設定を次に置き換えます。

Host foobar foobar.example.com
  Hostname foobar.example.com
  IdentityFile ~/.ssh/id_ed25519
  IdentitiesOnly yes

Host *
  IdentityFile ~/.ssh/id_ed25519
  IdentityFile ~/.ssh/id_rsa
  IdentitiesOnly yes

おすすめ記事