古いPuTTY利用でGitHubに接続できず

久しぶりにGitHubへ接続したところエラーが表示された。

FATAL ERROR: Couldn’t agree a key exchange algorithm (available: curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521)

このときの環境は次の通り。

  • Windows 10 Pro 64bit
  • git for Windows 2.16.2
    • plink接続
  • PuTTY 0.67 32bit

メッセージで検索したところ、関係しているGitHub側の変更は2018年2月に行われたWeak cryptographic standards removed | The GitHub Blogになる。弱い認証方式をGitHub側で無効にしているので、クライアント側が強い認証方式に対応できるようにする必要がある。

Earlier today we permanently removed support for the following weak cryptographic standards on github.com and api.github.com:

  • TLSv1/TLSv1.1: This applies to all HTTPS connections, including web, API, and Git connections to https://github.com and https://api.github.com.
  • diffie-hellman-group1-sha1: This applies to all SSH connections to github.com
  • diffie-hellman-group14-sha1: This applies to all SSH connections to github.com

Git BashをOpenSSHではなくPlinkで接続するようにインストール時に指定しているのでPuTTYの接続設定を確認してみると、鍵交換アルゴリズムとしてDH(diffie-hellman)が並んでいる。

当初利用していたPuTTYが2016年3月にリリースされた0.67なので古い。まずは最新のPuTTY 0.70へ更新することに。ChangeLogを確認すると0.68でECDHの強化が入っており、これが必要だったと思われます。

These features were new in 0.68 (released 2017-02-21):

  • Support for elliptic-curve cryptography (the NIST curves and 25519), for host keys, user authentication keys, and key exchange.

また今まで32bit版を利用していたので一度アンインストールし、PuTTY 0.70 64bitを入れ直した。入れ直しに伴い今まで利用していた設定は引き継がれたが、Git Bashの利用しているGIT_SSH環境変数「C:\Program Files (32bit)\PuTTY\plink.exe」の値を「GIT_SSH=C:\Program Files\PuTTY\plink.exe」へ修正必要があった。GIT_SSH環境変数はユーザ環境変数ではなくシステム環境変数として設定されていた。システム環境変数の修正反映はシステム再起動を伴うと思っていたが、Windows 10ではシステム環境変数の修正を行い、その後Git Bashを開き直すだけで反映されていた。

改めて鍵交換アルゴリズムを確認してみると「ECDH key exchange」が増えている。この状態で接続したところ、無事にgithub.comへSSH出来るようになった。

なお、PuTTYから接続したときのイベントログをとっておいた。イベントログを確認すると「ECDH key exchange」と記載があるので、アルゴリズムが追加されているPuTTY 0.67以前が接続できない影響を受けていると思われます。

2018-04-10 04:52:02 Connecting to 192.30.255.112 port 22
2018-04-10 04:52:02 We claim version: SSH-2.0-PuTTY_Release_0.70
2018-04-10 04:52:02 Server version: SSH-2.0-libssh_0.7.0
2018-04-10 04:52:02 Using SSH protocol version 2
2018-04-10 04:52:02 Doing ECDH key exchange with curve Curve25519 and hash SHA-256
2018-04-10 04:52:02 Server also has ssh-dss host key, but we don't know it
2018-04-10 04:52:02 Host key fingerprint is:
2018-04-10 04:52:02 ssh-rsa 2048 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48
2018-04-10 04:52:02 Initialised AES-256 SDCTR client->server encryption
2018-04-10 04:52:02 Initialised HMAC-SHA-256 client->server MAC algorithm
2018-04-10 04:52:02 Initialised AES-256 SDCTR server->client encryption
2018-04-10 04:52:02 Initialised HMAC-SHA-256 server->client MAC algorithm
2018-04-10 04:52:02 Reading key file "C:\Users\*.ppk"
2018-04-10 04:52:03 Offered public key
2018-04-10 04:52:03 Offer of public key accepted
2018-04-10 04:52:03 Sent public key signature
2018-04-10 04:52:03 Access granted
2018-04-10 04:52:03 Opening session as main channel
2018-04-10 04:52:03 Opened main channel
2018-04-10 04:52:03 Started a shell/command
2018-04-10 04:52:03 Server sent command exit status 1
2018-04-10 04:52:05 Disconnected: All channels closed

結局のところ、最新のPuTTYを使っておけば問題は起きなかった。セキュリティ維持のサービス変更は避けられないので、定期的に利用し適宜追従していきたい。


Posted

in

by

Tags:

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *