LoginSignup
1
1

More than 3 years have passed since last update.

Git for Windows で急に ssh 経由の git fetch / clone が動作しなくなったのを修正した

Posted at

数日前まで普通に使えていたはずの Git for Windows が急に permission denied のエラーを吐くようになり、git fetchgit clone もできなくなってしまいましたが、OpenSSH のバージョンアップをすることで直りました。

ネットを探しても、git で permission denied が出るのは SSH の鍵の登録漏れであるという前提の対処法ばかり出てきますが、SSH の鍵を登録しても permission denied になる場合、この記事が参考になるかもしれません。

環境

  • 発生日:2020/12/19
  • OS:Windows 10
  • Git のバージョン: 2.29.2.windows.3
  • リモートリポジトリの場所:gitlab.com

前提条件

数日前までは普通に git fetchgit clone もできていました。(つまり、SSH の鍵の登録漏れではありません。)

事象

git fetchgit clone も以下のような出力をして終了しました。

$ git fetch
warning: agent returned different signature type ssh-rsa (expected rsa-sha2-512)
git@gitlab.com: Permission denied (publickey,keyboard-interactive).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

なお、SSH の鍵を作り直して登録しなおしても、Git for Windows を再インストールしても、全く効果がありませんでした。

解決方法

Install Win32 OpenSSH · PowerShell/Win32-OpenSSH Wiki に沿って OpenSSH を更新しました。
すると、以下のように git コマンドが期待通り動作するようになりました。

$ git fetch
remote: Enumerating objects: 302, done.
remote: Counting objects: 100% (302/302), done.
remote: Compressing objects: 100% (131/131), done.
remote: Total 709 (delta 144), reused 283 (delta 128), pack-reused 407
Receiving objects: 100% (709/709), 144.01 KiB | 49.00 KiB/s, done.
Resolving deltas: 100% (348/348), completed with 10 local objects.
From gitlab.com:MusicScience37/mprpc
   c550fcf..427f50e  develop            -> origin/develop
 * [new branch]      feat/python_server -> origin/feat/python_server

考えられる要因

Windows に入っている OpenSSH が古いため、暗号化に使用するアルゴリズムが古く、Git リポジトリのサーバに拒否されたのではないかと思っています。

参考

1
1
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
1
1