SVN + SSH,不必每次都做ssh-add? (苹果系统)

我知道答案就在那里,但我非常愚蠢,可能不会意识到解决scheme,如果它打击我的脸。

我在Mac上,通过SSH隧道连接到SVN服务器。 每次我想连接到SVN服务器(基石和Xcode都连接到SVN),我必须ssh-add privateKey.txt

有没有办法在某处“保存”钥匙,所以我不必每次都这样做? 将它添加到我的钥匙串? 一些configuration文件? 启动脚本?

首先,将您的私钥文件移动到~/.ssh 。 这不是绝对必要的,但它是这种事情的标准地方。

然后运行ssh-add -K ~/.ssh/privateKey.txt 。 它会提示您的密码,如果有必要,然后将其添加到您的钥匙串。

之后,你不应该做任何事情。 稍长的解释可以在这里find 。

在密钥链中存储密码短语

要在钥匙串中存储默认密钥的密码,请打开terminal并运行:

 ssh-add -K 

并存储不同密钥运行的密码:

 ssh-add -K /path/to/private/key/file 

当提示您input密码时,就是这样。

您将永远不需要运行ssh-add,也不需要再input密码。

从这个网站采取的答案: http : //www-uxsup.csx.cam.ac.uk/~aia21/osx/leopard-ssh.html

经过多番探索,我想我已经完全find了这个问题的答案。 首先,确保你做了ssh-add -K ~/.ssh/your_key_here 。 这将钥匙添加到您的钥匙链中。 有些地方,我读过这个就够了,但是我不确定。 这也是特定于mac的,所以如果你需要在另一个unix版本上做这个,你将不会有这个选项。

为了好的措施,我编辑了~/.ssh/config文件(你可能需要创build它)来指向我所有的密钥。 矿有以下几点:

 IdentityFile ~/.ssh/identity IdentityFile ~/.ssh/id_rsa IdentityFile ~/.ssh/id_dsa IdentityFile ~/.ssh/my_other_identity_here IdentityFile ~/.ssh/yet_another_identity_here 

根据ssh_config的手册页 ,它将按顺序尝试。 我不知道我列出的前三个默认列表是否需要在那里,但是我已经包括了它们。

我没有太多的经验,所以不知道这个版本是否适合你,但看看http://www.phil.uu.nl/~xges/ssh/

如果这个特定的应用程序不起作用,那就是你正在寻找的东西 – ssh agent 。 在类似unix的盒子上,你可能希望通过它来启动整个窗口pipe理器,以获得全局效果,但是在osx中​​可能无法实现。

更多信息: http : //www-uxsup.csx.cam.ac.uk/~aia21/osx/leopard-ssh.html

从MacOS 10.12.2开始,您可以使用UseKeychain选项。 在这里阅读更多信息或查看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''. 

所以只要做到以下几点:

echo "UseKeychain yes" >> ~/.ssh/config

sshkeychain是一种可能性。 安装罚款与macports使用:

 sudo port install sshkeychain 

它使用钥匙串来存储密码,你可以简单地在login会话启动时启动它(在第一次启动时使用通常的右键点击Dock的图标+“在启动时启动”)

请注意,苹果的svn使用钥匙串来存储密码,但不一定是你用macports构build的svn二进制文件。