andybest
V2EX  ›  问与答

Mac OS的终端能共享SSH Key吗?

  •  
  •   andybest · Jul 17, 2013 · 4440 views
    This topic created in 4711 days ago, the information mentioned may be changed or developed.
    例如我在我mac上保存了SSH私钥,公钥上传至github
    然后我把同样公钥上传至我的一台ubuntu VPS

    在我mac上使用 ssh x.x.x.x 这样直接登陆VPS
    然后在VPS上执行 git clone ssh://github... 后出现:
    Permission denied (publickey).
    fatal: The remote end hung up unexpectedly

    我知道这个错误的原因是VPS上并没有储存SSH私钥导致的,但将私钥上传至VPS又感觉不安全

    既然这个私钥已存在在我的mac上,并且我用该私钥登陆了VPS,怎么样能在VPS上连接github呢?

    windows下的SecureCRT可以实现这个功能,但我试了mac版的SecureCRT却不行,用mac能否解决这个问题?各位用mac开发对于这个问题的是怎么做的呢?

    感谢 :)
    10 replies    1970-01-01 08:00:00 +08:00
    yuelang85
        1
    yuelang85  
       Jul 17, 2013   ❤️ 1
    ssh -A ?
    chemhack
        2
    chemhack  
       Jul 17, 2013   ❤️ 1
    "我知道这个错误的原因是VPS上并没有储存SSH私钥导致的,但将私钥上传至VPS又感觉不安全"

    Are you sure? VPS上有公钥就可以了。。。。 要把私钥放在~/.ssh/authorized_keys下,或者你ssh-copy-id也可以
    andybest
        3
    andybest  
    OP
       Jul 17, 2013
    @yuelang85 VPS上需要执行的时git xxx命令,不是ssh命令啊
    andybest
        4
    andybest  
    OP
       Jul 17, 2013
    @chemhack 谢谢,vps上是只有公钥,问题是vps无法使用git clone这样访问github

    在vps的~/.ssh/authorized_keys里保存的是公钥
    alexrezit
        5
    alexrezit  
       Jul 17, 2013   ❤️ 2
    @yuelang85
    正解. 连接 VPS 的时候用 -A.
    yuelang85
        6
    yuelang85  
       Jul 17, 2013   ❤️ 1
    @andybest ssh -A上vps。这样可以随着连接,vps继承到ssh使用的私钥。就是传递私钥功能啦。
    dorentus
        7
    dorentus  
       Jul 17, 2013   ❤️ 1
    常用的方法应该是在 VPS 再生成一对密钥然后把公钥添加到 github 里面吧。这样万一哪天不用了,直接在 github 里面撤销这个密钥的访问权就可以了。

    其实不光是 VPS,在任意机器上都应该这么做吧。
    BOYPT
        8
    BOYPT  
       Jul 17, 2013   ❤️ 1
    你不会在vps再生成一对key,pubkey再写到github么。
    andybest
        9
    andybest  
    OP
       Jul 17, 2013
    @yuelang85
    @BOYPT

    非常感谢! :)
    chemhack
        10
    chemhack  
       Jul 17, 2013   ❤️ 1
    @andybest 是的,笔误。。。。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3103 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 63ms · UTC 14:18 · PVG 22:18 · LAX 07:18 · JFK 10:18
    ♥ Do have faith in what you're doing.