bash 用于 ssh-add 的钥匙串
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10622291/
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
Keychain for ssh-add
提问by TheFrack
I need to pull from Github all the time and I have a passphrase, but it's a pain, so I typically run...
我需要一直从 Github 拉取数据并且我有一个密码短语,但这很痛苦,所以我通常运行...
ssh-agent bash
ssh-add ~/.ssh/id_rsa
<prompt and give passphrase>
And that works for the session, but even after I logout, I would like it to save the passphrase next time I PuTTY in. So I installed keychain, but I'm too dumb to operate it. I tried this...
这对会话有效,但即使在我注销后,我也希望下次我 PuTTY 时保存密码。所以我安装了钥匙串,但我太笨了,无法操作它。我试过这个...
/usr/bin/keychain ~/.ssh/id_dsa
And it said it added my passphrase, but it didn't work :(
它说它添加了我的密码,但它不起作用:(
How would I call keychain so it saves my passphrase for Git?
我将如何调用钥匙串,以便为 Git 保存我的密码?
Edit: Apologies for posting this on stackoverflow, it technically doeshave some relevance to programming as it has to do with Git, but my apologies for not posting it on SuperUser.
编辑:很抱歉在 stackoverflow 上发布此内容,从技术上讲,它确实与编程有关,因为它与 Git 相关,但我很抱歉没有将其发布在 SuperUser 上。
回答by Todd A. Jacobs
You actually need to invoke keychain differently. Add the following to your ~/.bashrcfile:
您实际上需要以不同的方式调用钥匙串。将以下内容添加到您的~/.bashrc文件中:
eval `keychain --eval id_rsa`
See the keychain documentationfor more information about how to set it up properly for your specific shell or system, or if you have more complex requirements.
有关如何为您的特定 shell 或系统正确设置它的更多信息,或者如果您有更复杂的要求,请参阅钥匙串文档。
回答by TheFrack
Okay this is the best I could come up with...
好吧,这是我能想到的最好的……
Install keychain...
安装钥匙扣...
Then add the following to ~/.bashrcfile:
然后将以下内容添加到~/.bashrc文件中:
eval `keychain --eval id_rsa`
THEN add the following to ~/.bash_profile:
然后将以下内容添加到~/.bash_profile:
ssh-agent bash
That will start keychain. It isn't as simple as just putting both in the bash profile or bashrc file.
这将启动钥匙串。这并不像将两者都放在 bash 配置文件或 bashrc 文件中那么简单。
回答by j?rgensen
You have to keep the keys in a "persistent" state so to say. This can be done by having an agent open one on the local side, combined with?— in case of openssh?— ssh -A. Then, ssh-add on the remote server will cause the keys to be opened and retained on the local desktop, such that, when logging in again on the remote side, the keys are already available.
可以这么说,您必须将密钥保持在“持久”状态。这可以通过让一个代理在本地打开一个代理来完成,结合?- 在 openssh?- 的情况下ssh -A。然后,远程服务器上的 ssh-add 将导致密钥被打开并保留在本地桌面上,以便在远程端再次登录时,密钥已经可用。

