Windows SourceTree で GitHub への git clone, fetch, pushなどができない

Git
GitHub

概要

Windows SourceTree で git clone, fetch, pushなど、
GitHubへのアクセスができない。

詳細を見ると、こんなエラーが出ている。

The host key is not cached for this server:
  github.com (port 22)
You have no guarantee that the server is the computer
you think it is.
The server's ssh-ed25519 key fingerprint is:
  ssh-****************************************
If you trust this host, enter "y" to add the key to
PuTTY's cache and carry on connecting.
If you want to carry on connecting just once, without
adding the key to the cache, enter "n".
If you do not trust this host, press Return to abandon the
connection.
Store key in cache? (y/n, Return cancels connection, i for more info) y
Using username "git".
Access granted. Press Return to begin session.
Server refused to allocate pty
Hi USER_NAME! You've successfully authenticated, but GitHub does not provide shell access.

原因

PuTTYのキャッシュが原因のよう。
SourceTreeのインストールディレクトリの中の、toolディレクトリにあるexeからputtyを実行してあげれば、
うまいことできました。

解決方法

SourceTreeのディレクトリにターミナルで行きます。

USER_NAMEは、ご自身のPCのユーザ名に変えてください。

C:\Users\USER_NAME\AppData\Local\SourceTree\

次にapp-*.*.**(*は何かしらの数字)のような、SourceTreeのバージョンが入ったディレクトリがあると思うので、
そのバージョンの中に入ります。
2023/06/01時点ではapp-3.4.13でした。

更にその中のtools\puttyディレクトリに移動します。
まとめると以下のような感じです。

$ cd C:\Users\USER_NAME\AppData\Local\SourceTree\app-3.4.13\tools\putty

そのまま、以下のコマンドを実行します。

.\plink.exe -ssh -C -i "鍵ファイルまでの絶対パス" git@github.com

すると

Store key in cache? (y/n, Return cancels connection, i for more info)

のように聞かれるのでyを入力します。

これで接続できるようになると思います。

参考