首页 文章

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

提问于
浏览
102

我知道答案就在那里,但我非常愚蠢,如果它让我面目全非,可能无法识别解决方案 .

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

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

7 回答

  • 49

    首先,将您的私钥文件移动到 ~/.ssh . 这不是绝对必要的,但它是这类事物的标准位置 .

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

    在那之后,你不应该做任何其他事情 . 有一个稍微长一点的解释here .

  • 1

    Storing Passphrases in the Keychain

    要在Keychain中存储默认密钥的密码,请打开终端并运行:

    ssh-add -K
    

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

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

    当提示您输入密码时,请输入它,就是这样 .

    您永远不需要运行ssh-add,也不需要再次输入密码 .

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

  • 2

    经过多次探索,我想我已经完全找到了这个问题的答案 . 首先,确保你做 ssh-add -K ~/.ssh/your_key_here . 这会为您的钥匙串增加钥匙 . 有些地方,我已经读到这已经足够了,但我还没有这个选择 .

    为了更好地衡量,我编辑了 ~/.ssh/config 文件(您可能需要创建它)以指向我拥有的所有键 . 我有以下几点:

    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的man page,它将按顺序尝试这些 . 我不确定我列出的前三个默认值是否需要在那里,但无论如何我都包含了它们 .

  • 0

    从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''.
    

    So just do the following:

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

  • 5

    我对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

  • 19

    sshkeychain是一种可能性 . 使用以下命令安装macports:

    sudo port install sshkeychain
    

    它使用钥匙串存储密码,您可以在登录会话启动时启动它(在第一次启动时使用通常的右键单击停靠栏图标“启动时启动”)

    请注意,Apple的svn使用keychain来存储密码,但不一定是使用macports构建的svn二进制文件 .

  • 172

    通过运行以下命令将密钥添加到钥匙串:

    ssh-add -K ~/.ssh/id_rsa
    

    并编辑您的ssh配置( ~/.ssh/config )文件以自动将密钥链中的密钥加载到ssh-agent( AddKeysToAgent yes 选项)并在密钥链中存储密码( UseKeychain yes 选项):

    Host *
     AddKeysToAgent yes
     UseKeychain yes
    

相关问题