当密钥有密码时 Sublime Merge SSH 失败

Sublime Merge SSH Failing when Key has password

当我尝试克隆一个 repo 时,我得到一个 git failed with exit code 128

另外,当我尝试 push/pull 时,我得到 git@gitlab.com public key denied

在我的 ~/.ssh 文件夹中,我有一个 config 文件,如下所示:

Host mycompany.gitlab.com
    HostName gitlab.com
    User git
    PreferredAuthentications publickey
    IdentityFile ~/.ssh/gitlab-company-bryan

git 在终端中工作正常但 Sublime Merge 我收到权限错误。

我需要做什么才能让 Sublime 使用这个 public 密钥?我非常困惑,现在让它工作。

git in the terminal works fine but Sublime Merge I am getting permissions errors.

第一个:

私钥是用Git 2.19.2生成的,意思是openssh 7.8+,它刚刚改变了私钥的默认格式,从PEM(每行64个字符)到"OPENSSH"(每行 70 个字符)。
参见“Jenkins: what is the correct format for private key in Credentials

尝试重新生成私钥(并在 GitLab 上注册),但这次使用:

ssh-keygen -m PEM -t rsa -P "" -f mynewkey

也就是排除Sublime Merge对该键的任何解释错误。

其次,as the OP discussed here,似乎不支持带密码的 SSH 私钥,除非 ssh-agent 已正确配置为缓存所述密码。

KeyChain on macOS handles everything for me (without any ssh config; I'm still using the default id_rsa for all of my repos).

OP bryan confirms :

I finally got it working with:

ssh-add -K ~/.ssh/[your-private-key]

作为explained on GitHub:

The -K option is in Apple's standard version of ssh-add, which stores the passphrase in your keychain for you when you add an ssh key to the ssh-agent.

对于那些感兴趣的人,我首先从命令行启动 ssh-agent,然后使用 'ssh-add' 命令将我的密钥添加到 ssh-agent,然后在 Ubuntu 18.04 上运行它,然后在同一个打开的 tty 中,使用以下命令在当前目录上启动 Sublime Merge: smerge . &

这样,每次 Sublime Merge 使用您的 ssh 密钥时,后台的 ssh-agent 进程 运行 都会为您处理输入的密码。