git GitKraken 上的 SSH 密钥无效
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/41145054/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Invalid SSH keys on GitKraken
提问by shaNnex
Ok, so I have a git repo somewhere in a server in the other room and I've been using SourceTree before but it's just so annoying with the index.lock issue, and apparently this is the most common problem that most developer is experiencing with SourceTree. Although I found that it'll fix itself if I wait for few minutes to half a day, but I don't have the time to wait and I think it defeats the purpose of using git client at all.
好的,所以我在另一个房间的服务器中的某个地方有一个 git repo,我之前一直在使用 SourceTree,但是 index.lock 问题很烦人,显然这是大多数开发人员遇到的最常见问题源树。虽然我发现如果我等几分钟到半天它会自己修复,但我没有时间等待,我认为这完全违背了使用 git client 的目的。
But, this is not about SourceTree... So, I found GitKraken and it looks cool and I never have an issue with index.lock. The only problem is I am unable to push and pull to my server in the other room. I have configured my ssh keys and that. I can push/pull to github/bitbucket account but not next room. If ever you have encountered such problems, or if ever you have a tiny bit of idea on how I maybe able to solve my problem, please let me know. I have already made contact with the support team but response is very scarce.
但是,这与 SourceTree 无关……所以,我找到了 GitKraken,它看起来很酷,而且我从来没有遇到过 index.lock 问题。唯一的问题是我无法推拉到另一个房间的服务器。我已经配置了我的 ssh 密钥。我可以推/拉到 github/bitbucket 帐户,但不能推/拉到隔壁房间。如果您遇到过这样的问题,或者您对我如何解决我的问题有一点想法,请告诉我。我已经与支持团队取得了联系,但回复很少。
回答by gabeio
It seems that on my mac if I don't run ssh-add -k ~/.ssh/id_rsa
then I get errors about having a bad ssh key.
似乎在我的 Mac 上,如果我不运行,ssh-add -k ~/.ssh/id_rsa
则会收到有关 ssh 密钥错误的错误消息。
This also seems to work on Ubuntu (18.04).
这似乎也适用于 Ubuntu (18.04)。
回答by Jim Aho
Lots of answers already, and I think most of them are very helpful. I will still add some more information here, because I don't think any answer actually solves the problem all the way.
已经有很多答案了,我认为其中大多数都非常有帮助。我仍然会在这里添加更多信息,因为我认为没有任何答案能够真正解决问题。
This is what I did to solve it, from start, sitting on MacOS.
这就是我从一开始就坐在 MacOS 上解决它的方法。
- Run
ssh-keygen
to generate keys. I did provide a passphrase. - Run
ssh-add -K ~/.ssh/id_rsa
to save my identity inside my local ssh agent. This is important. Do note here that it's an uppercase -K, which means that I want to store my passphrase too inside the local ssh agent, this will cause it to store my passphrase in the keychainso I dont need to re-enter it all the time, very neat! - Inside Gitkraken, go to "Preferences -> authentication... -> General"
- Check "Use local SSH agent". This will tell Gitkraken to use my agent in step 2. If you don't do this then Gitkraken will use it's own bundled ssh agent and I think this is what cause problem for most people
- Add your
~/.ssh/id_rsa.pub
public key to your server (bitbucket.org, azure devops, github or w/e). - Now when you do
git fetch
from terminal or do git fetch from Gitkraken, it should both work. Gitkraken will use your computers own ssh agent which we have configured to authenticate us successfully.
- 运行
ssh-keygen
以生成密钥。我确实提供了密码。 - 运行
ssh-add -K ~/.ssh/id_rsa
以在本地 ssh 代理中保存我的身份。这个很重要。请注意,它是一个大写的 -K,这意味着我也想将我的密码存储在本地 ssh 代理中,这将导致它将我的密码存储在钥匙串中,因此我不需要一直重新输入它,非常整洁! - 在 Gitkraken 中,转到“首选项 -> 身份验证... -> 常规”
- 选中“使用本地 SSH 代理”。这将告诉 Gitkraken 在第 2 步中使用我的代理。如果你不这样做,那么 Gitkraken 将使用它自己捆绑的 ssh 代理,我认为这是大多数人遇到问题的原因
- 将您的
~/.ssh/id_rsa.pub
公钥添加到您的服务器(bitbucket.org、azure devops、github 或 w/e)。 - 现在,当您
git fetch
从终端执行操作或从 Gitkraken 执行 git fetch 时,它应该都可以工作。Gitkraken 将使用您的计算机自己的 ssh 代理,我们已将其配置为成功验证我们的身份。
Hope this helps some.
希望这对一些人有所帮助。
Update: I also had to include ssh-add -K ~/.ssh/id_rsa
inside my ~/.bash_profile
to make it load automatically, otherwise you'll have to run that command on every computer restart.
更新:我还必须包含ssh-add -K ~/.ssh/id_rsa
在 my 中~/.bash_profile
以使其自动加载,否则您必须在每次重新启动计算机时运行该命令。
回答by beepscore
On macOS I had a Private/Public key pair and GitKraken was sucessfully using it to push to a bitbucket repository. Public key file ~/.ssh/id_rsa.pub format is similar to Josh Patterson answer:
在 macOS 上,我有一个私有/公共密钥对,并且 GitKraken 成功地使用它来推送到一个 bitbucket 存储库。公钥文件 ~/.ssh/id_rsa.pub 格式类似于 Josh Patterson 的回答:
ssh-rsa AAAAB3NzaC1yc2...8swZ0Ew==
I created a second bitbucket repo. At some point gitKraken could no longer push to the first repo. I could still git push to first repo from terminal command line, manually entering passphrase.
我创建了第二个 bitbucket 存储库。在某些时候 gitKraken 无法再推送到第一个 repo。我仍然可以从终端命令行 git push 到第一个 repo,手动输入密码。
GitKraken said "Configured SSH key is in an invalid format. Please ensure that your key is valid and is an RSA-type key."
GitKraken 说“配置的 SSH 密钥格式无效。请确保您的密钥有效并且是 RSA 类型的密钥。”
Similar to Coming Sun's answer I went to GitKraken Preferences/Authentication/General. Unlike Coming Sun's answer I already had a Private/Public key and didn't want to generate a new pair. Instead I selected "Use local SSH agent". This fixed GitKraken for me.
类似于 Coming Sun 的回答,我去了 GitKraken Preferences/Authentication/General。与 Coming Sun 的回答不同,我已经有了一个私钥/公钥,不想生成新的一对。相反,我选择了“使用本地 SSH 代理”。这为我修复了 GitKraken。
回答by Corning Sun
- GitKraken -> Preferences -> Authentication -> Generate new Private/Public key;
- add the New Public key to your git server.
- GitKraken -> Preferences -> Authentication -> Generate new Private/Public key;
- 将新公钥添加到您的 git 服务器。
回答by Tom Mac
I got mine working by using a combination of gabeios answer and also turning the option 'use local ssh agent' on and off (gitkraken preferences > authentication > 'use local ssh agent').
我通过使用 gabeios 答案的组合并打开和关闭选项“使用本地 ssh 代理”(gitkraken 首选项 > 身份验证 >“使用本地 ssh 代理”)让我的工作正常进行。
I turned it off and tried gabeios answer and it didn't work but then turned it on and tried again with gabeios answer. Some combination of the two worked with me for some reason. I'm on mac. Hope it helps.
我将其关闭并尝试了 gabeios answer,但没有奏效,但随后将其打开并再次尝试使用 gabeios answer。出于某种原因,两者的某种组合对我有用。我在 mac 上。希望能帮助到你。
回答by Josh Patterson
So in case this helps someone else (or me once I've forgotten), it appears that GIT Kraken is very picky about its public key format, and does NOT support what I think of the standard format. I usually see keys that look like:
因此,如果这对其他人有帮助(或者一旦我忘记了我),GIT Kraken 似乎对其公钥格式非常挑剔,并且不支持我认为的标准格式。我通常看到的键看起来像:
---- BEGIN SSH2 PUBLIC KEY ----
Comment: "rsa-key-20181204"
AAAAB3NzaC1yc2EAAAABJQAAAQEA5kpsxjtSZ4kMyKIBy0ASQShN/BSAEa7d4lrL
...
hA2TX0L2fLKDkpzCngkDgGbLDxj5dXTN4gpnZdr7lzMciFQu0uhfTLmeYgi1nFOi
KfJ+cQWg3uOHQ0zd8/2GyvfARWy3nZDFoLSQTrbErkX8swZ0Ew==
---- END SSH2 PUBLIC KEY ----
Git Kraken seems to insist on this format:
Git Kraken 似乎坚持这种格式:
ssh-rsa AAAAB3NzaC1yc2...8swZ0Ew==
You can see this is the "same" key but it needs to be in the simpler format for Git Kraken to be happy with it.
您可以看到这是“相同”的键,但它需要采用更简单的格式才能让 Git Kraken 满意。
Thanks, Josh
谢谢,乔希
回答by LIN Hongbin
gabeio's answer works. To avoid calling ssh-add -K ~/.ssh/id_rsa
in the terminal every single time, it can be add to the profile file.
gabeio 的回答有效。为了避免ssh-add -K ~/.ssh/id_rsa
每次都在终端中调用,可以将其添加到配置文件中。
You can put it to ~/.bash_profile
:
你可以把它放在~/.bash_profile
:
put
ssh-add -K ~/.ssh/id_rsa
inside your~/.bash_profile
放入
ssh-add -K ~/.ssh/id_rsa
你的~/.bash_profile
But it requires to open the terminal to execute this line.
但它需要打开终端才能执行这一行。
In my case, I added it to /etc/profile
. Add the line, ssh-add -K ~/.ssh/id_rsa
at the bottom of /etc/profile
. Here are the instructions in the terminal:
就我而言,我将其添加到/etc/profile
. ssh-add -K ~/.ssh/id_rsa
在 底部添加该行/etc/profile
。以下是终端中的说明:
- Change permission of the file,
$sudo chmod 644 /etc/profile
- Edit the file,
$sudo nano /etc/profile
- Add this line at the bottom of the file,
ssh-add -K ~/.ssh/id_rsa
. - Close and save the file
- Reboot.
- 更改文件的权限,
$sudo chmod 644 /etc/profile
- 编辑文件,
$sudo nano /etc/profile
- 在文件底部添加这一行,
ssh-add -K ~/.ssh/id_rsa
. - 关闭并保存文件
- 重启。
It works for me without opening the terminal every time. Hope it can help.
它对我有用,而无需每次都打开终端。希望它能有所帮助。
回答by Baldráni
Preferences... > Authentication
首选项... > 身份验证
I just had to switch to
我只需要切换到
[ ] Use local SSH agent
[ ] 使用本地 SSH 代理
Instead of using the path to my local ssh
而不是使用我本地 ssh 的路径
回答by junderdo
Make sure your remote is set correctly. Gitkraken will allow you to clone by pasting in the "git clone" command but it will erroneously set that as the origin
确保您的遥控器设置正确。Gitkraken 将允许您通过粘贴“git clone”命令进行克隆,但它会错误地将其设置为原点
回答by israel Villacís
If you are trying to access a repository in Githubbut it doesn't work.
如果您尝试访问Github 中的存储库但它不起作用。
This worked for me:
这对我有用:
First, watch if you have "write access"in your Repository
首先,注意您的存储库中是否具有“写访问权限”
(Setting -> Manage Access)
If the error persists:
如果错误仍然存在:
Disconnect Github account in Gitkraken
(File-> Preferences -> Authentication -> Github -> Disconnect)
Revoque Access to Gitkraken in Github
(Settings-> Applications -> Authorized Oauth Apps -> Gitkraken -> Revoke)
Connect again Gitkraken to Github
(make sure that you give permission to all your repositories)
在 Gitkraken 中断开 Github 帐户
(File-> Preferences -> Authentication -> Github -> Disconnect)
在 Github 中取消对 Gitkraken 的访问
(Settings-> Applications -> Authorized Oauth Apps -> Gitkraken -> Revoke)
再次连接 Gitkraken 到 Github
(make sure that you give permission to all your repositories)
I hope this will be helpful to you :)
我希望这对你有帮助:)