shily
V2EX  ›  macOS

[求助]每次使用 ssh 时,都需要输入私钥的密码

  •  2
     
  •   shily · Feb 16, 2017 · 11188 views
    This topic created in 3402 days ago, the information mentioned may be changed or developed.

    如题,每次使用 ssh 时,都需要输入私钥的密码

    shily at Shily-Book-pro in ~/work/x-android (feature-v5)
    $git pull --rebase
    Enter passphrase for key '/Users/shily/.ssh/id_ras':
    

    已经更新到 10.12.3 后,不知道怎么搞的,每次使用 ssh 时都需要输入私钥的密码, ssh-agent 并没有自动解锁私钥。 执行 ssh-add /Users/shily/.ssh/id_ras 可以解决,但每次重启都需要进行一次,稍显蛋疼。
    求助。

    14 replies    2017-02-20 13:33:59 +08:00
    bao3
        1
    bao3  
       Feb 16, 2017
    密钥系统可以记住的。。。。。
    mxi1
        2
    mxi1  
       Feb 16, 2017 via iPhone
    为什么会用到私钥呢?😓
    rrfeng
        3
    rrfeng  
       Feb 16, 2017
    openssl *** -in xxx -out yyy
    rogerchen
        4
    rogerchen  
       Feb 16, 2017
    ~/.ssh/config 中加入

    [email protected]
    IdentityFile ~/.ssh/id_rsa
    Tiande
        5
    Tiande  
    PRO
       Feb 16, 2017   ❤️ 1
    重新生成一个 key ,在设置 passphrase 的时候直接 回车 跳过就好了...

    或者想办法把现在这个 key 的 passphrase 清掉。
    sinker
        6
    sinker  
       Feb 16, 2017 via iPhone
    加个启动项执行 ssh-add -A
    QAPTEAWH
        7
    QAPTEAWH  
       Feb 16, 2017   ❤️ 2
    https://github.com/jirsbek/SSH-keys-in-macOS-Sierra-keychain

    见 Solution 1 ,我自己还没试。之前用的 Solution 2 。
    julyclyde
        8
    julyclyde  
       Feb 18, 2017
    你是不是换过 openssh 啊?
    mac 版 openssh 是定制过的,会用 keychain 记住
    shily
        9
    shily  
    OP
       Feb 20, 2017
    @bao3 以前是可以的,就是最近莫名的记不住了。
    @mxi1 git 拉取代码配置的 ssh 模式,使用的
    @rrfeng 没有看懂
    @rogerchen 已经配置了,否则就不是提示要输入密码了。
    @Tiande 我也知道可以生成新的 key, 还有别的解决方式吗?
    shily
        11
    shily  
    OP
       Feb 20, 2017
    @sinker 神奇,使用命令 ssh-add -A 时,竟然不需要输入密码。
    @julyclyde 不知道,你是说 openssl 吗?我看 brew list 中有 openssl
    rrfeng
        12
    rrfeng  
       Feb 20, 2017
    openssl rsa -in KEY -out NEW_KEY

    提示输入 key 的密码,然后生成的 NEW_KEY 就不需要密码了。
    shily
        13
    shily  
    OP
       Feb 20, 2017   ❤️ 1
    @QAPTEAWH
    使用 Solution 1 解决问题,
    在 ~/.ssh/config 中添加
    ```
    UseKeychain yes
    AddKeysToAgent yes
    ```
    解决了问题
    shily
        14
    shily  
    OP
       Feb 20, 2017
    @Tiande
    @rrfeng
    谢谢两位,估计你们想表达的意思是同样的。
    参考 #7 的回复,问题已经解决。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   4064 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 58ms · UTC 05:22 · PVG 13:22 · LAX 22:22 · JFK 01:22
    ♥ Do have faith in what you're doing.