密钥具有密码时,Sublime Merge SSH失败 [英] Sublime Merge SSH Failing when Key has password

查看:496
本文介绍了密钥具有密码时,Sublime Merge SSH失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

When I try to clone a repo I get a git failed with exit code 128.

另外,当我尝试推/拉时,我得到一个git@gitlab.com public key denied.

Also when I try to push/pull I get a git@gitlab.com public key denied.

在我的〜/.ssh文件夹中,有一个config文件,看起来像这样:

In my ~/.ssh folder I have a config file that looks like this:

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

终端中的git工作正常,但是Sublime Merge我遇到权限错误.

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

我需要做什么才能让Sublime使用此公钥?我非常困惑,目前无法正常工作.

What do I need to do so that Sublime Uses this public key? I'm super confused and get it to work at the moment.

推荐答案

终端中的git工作正常,但是Sublime Merge我遇到权限错误.

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:凭据中私钥的正确格式是什么"

The private key has been generated with Git 2.19.2, meaning an openssh 7.8+, which has just changed its private key default format, from PEM (64 characters per lines) to "OPENSSH" (70 characters per lines).
See "Jenkins: what is the correct format for private key in Credentials"

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

Try and regenerate a private key (and register it on GitLab), but this time with:

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

这是排除Sublime Merge对该键的任何解释错误.

That is to rule out any interpretation error of that key by Sublime Merge.

其次,如在此处讨论的OP 中,似乎不支持带有密码短语的SSH私钥,除非ssh-agent已正确配置为缓存所述密码短语.

Second, as the OP discussed here, SSH private keys with passphrase don't seem to be supported, unless the ssh-agent is properly configured to cached said passphrase.

macOS上的KeyChain可以为我处理所有事情(无需任何ssh配置;我仍对所有存储库使用默认的id_rsa).

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 确认

我终于可以使用它了:

I finally got it working with:

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

在GitHub上解释:

-K选项在Apple的ssh-add标准版本中,当您将ssh密钥添加到ssh-agent时,该密码将密码短语存储在您的钥匙串中.

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.

这篇关于密钥具有密码时,Sublime Merge SSH失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆