从macOS 10.12.2开始,您可以使用 UseKeychain 选项 . Read more here或查看 man ssh_config .
UseKeychain
On macOS, specifies whether the system should search for passphrases in the user's keychain
when attempting to use a particular key. When the passphrase is provided by the user, this
option also specifies whether the passphrase should be stored into the keychain once it has
been verified to be correct. The argument must be ``yes'' or ``no''. The default is ``no''.
7 回答
首先,将您的私钥文件移动到
~/.ssh
. 这不是绝对必要的,但它是这类事物的标准位置 .然后运行
ssh-add -K ~/.ssh/privateKey.txt
. 如有必要,它会提示您输入密码,然后将其添加到您的钥匙串中 .在那之后,你不应该做任何其他事情 . 有一个稍微长一点的解释here .
Storing Passphrases in the Keychain
要在Keychain中存储默认密钥的密码,请打开终端并运行:
并为不同的密钥运行存储密码:
当提示您输入密码时,请输入它,就是这样 .
您永远不需要运行ssh-add,也不需要再次输入密码 .
从本网站获取的答案:http://www-uxsup.csx.cam.ac.uk/~aia21/osx/leopard-ssh.html
经过多次探索,我想我已经完全找到了这个问题的答案 . 首先,确保你做
ssh-add -K ~/.ssh/your_key_here
. 这会为您的钥匙串增加钥匙 . 有些地方,我已经读到这已经足够了,但我还没有这个选择 .为了更好地衡量,我编辑了
~/.ssh/config
文件(您可能需要创建它)以指向我拥有的所有键 . 我有以下几点:根据ssh_config的man page,它将按顺序尝试这些 . 我不确定我列出的前三个默认值是否需要在那里,但无论如何我都包含了它们 .
从macOS 10.12.2开始,您可以使用
UseKeychain
选项 . Read more here或查看man ssh_config
.So just do the following:
echo "UseKeychain yes" >> ~/.ssh/config
我对mac没有太多经验,所以不确定这个版本是否适合你,但看看http://www.phil.uu.nl/~xges/ssh/
如果这个特定的应用程序没有't work, that' s无论如何你正在寻找 -
ssh agent
. 在类似unix的盒子上,你想要通过它启动整个窗口管理器,以获得全局效果,但在osx中可能无法实现 .更多信息:http://www-uxsup.csx.cam.ac.uk/~aia21/osx/leopard-ssh.html
sshkeychain是一种可能性 . 使用以下命令安装macports:
它使用钥匙串存储密码,您可以在登录会话启动时启动它(在第一次启动时使用通常的右键单击停靠栏图标“启动时启动”)
请注意,Apple的svn使用keychain来存储密码,但不一定是使用macports构建的svn二进制文件 .
通过运行以下命令将密钥添加到钥匙串:
并编辑您的ssh配置(
~/.ssh/config
)文件以自动将密钥链中的密钥加载到ssh-agent(AddKeysToAgent yes
选项)并在密钥链中存储密码(UseKeychain yes
选项):