12
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Windows の OpenSSH で認証できなくなった話

Posted at

Windows がアップデートされたことで、今まで動いていた構成が急に動かなくなりました。
なぜこうなったのか、どうやって解決したか記録しておきます。

こんな構成にしていた

できるだけ Microsoft が提供しているものを使う・それ以外は Pageant だけ、という構成にして運用していました。

+-------------------------------------------------------------+
| Windows                                                     |
|   VSCode                                                    |
|     Remote SSH                                              |
|       ssh.exe (Windows搭載) --- Pageant                     |
|         |  .ssh/config           --openssh-config オプション |
|         |     pageant.conf <---------+                      |
+---------|---------------------------------------------------+
          |
+---------|--------------------------+
| Linux  sshd                        |
|   ここにあるファイルを VSCode で編集 |
+------------------------------------+

起きた問題と解析

ある日突然(ユーザはこれを「何もしていないのに」と言う)、VSCode で Linux サーバのファイルを見ようとしたところ SSH 接続ができなくなりました。
VSCode の エラーメッセージは Could not establish connection to "xxx.example.com". というものでした。
OUTPUT では プロセスが、存在しないパイプに書き込もうとしました。 というエラーが出ていました。

  • (get-childitem \\.\pipe\).FullName で確認したところ、pipe は作成されている
    • pipe 名は \\pipe.\pageant.(ユーザ名).(ランダム文字列)
  • pageant.conf には同じ pipe 名が書き込まれている
  • ssh.exe -vvv で接続して詳細を確認
    • debug3: unable to connect to pipe \\.\\pipe\\pageant.(ユーザ名).(ランダム文字列), error: 3

Windows の OpenSSH がアップデートされたことを知っていたので、OpenSSH 8.6p1(Windows アップデートがあたっていないマシンの ssh.exe を持ってきた)で接続したところ、問題なく接続できました。
OpenSSH 8.6p1 では接続できて、9.5p1 だと Pageant に接続できないという状況がわかりました。

また、ssh.exe が表示するパイプ名だけ、. 以降の \ が重複していることに気づいて調べていったら GitHub に issue を見つけました。
https://github.com/powershell/win32-openssh/issues/1949#issuecomment-2404790143
PuTTY 0.79 から、使われる記号が \ から / に変更されたそうです。
使っていた Pageant は 0.78 のものでした。

まとめ

原因1. Windows の OpenSSH がアップデートされた

2024年10月のセキュリティ更新プログラムで OpenSSH にアップデートが入り、OpenSSH のバージョンが 8.6p1 から 9.5p1 に上がりました。

Before
OpenSSH_for_Windows_8.6p1, LibreSSL 3.4.3
2022-05-06 23:15
1,073,152 bytes

After
OpenSSH_for_Windows_9.5p1, LibreSSL 3.8.2
2024-10-09 09:07
1,243,648 bytes

OpenSSH 8.9 でパスの区切り記号の扱いが変更されたものと思われます。(後述の PuTTY のコミットログによる)

原因2. 使っていた Pageant が古かった

Pageant 0.79 でパイプ名の区切り記号が変更されました。これは OpenSSH の変更への対策のようです。
Pageant を 0.78 のものから最新 (0.81) のものにしたら、pageant.conf ファイルに出力されるパイプ名が //pipe./pageant.(ユーザ名).(ランダム文字列) になりました。
OpenSSH 9.5p1 の ssh.exe(Windows のもの)からサーバに接続できるようになりました。

おわりに

できるだけ導入が簡単になるよう Microsoft が提供するものだけを使っていても、Windows アップデートによりバージョンが変わり、バージョンの組み合わせによる問題が起きるものだな、という経験をしました。

12
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
12
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?