SourceTree SSH第一次登录需要交互确认的问题

发布时间 2023-12-31 13:13:42作者: 思wu邪

问题

在SourceTree SSH配置完ssh之后向上提交代码的时候发现:

The server's host key is not cached in the registry. You
have no guarantee that the server is the computer you
think it is.
The server's rsa2 key fingerprint is:
ssh-rsa 2048 **:**:**:**:**:**:**:**:**:**:**:**:**:**:**:**
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)

问题是没法按y。这样的话就一直没法提交代码了。

解决方案

一共有两种解决方案
1.在界面上使用命令行模式推送代码。如下:

2.初始化putty。因为source Tree好像是使用putty作为秘钥验证的工具。具体做法为:

  • 找到putty路径,默认在: SourceTree\app-3.4.12\tools\putty,进入这个路径
  • 在此处打开命令行,运行:plink git@github.com即可。
PS C:\Users\Administrator\AppData\Local\SourceTree\app-3.4.16\tools\putty> ./plink git@github.com
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:
  xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
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 578223592