【问题标题】:git + bitbucket - ssh script issuesgit + bitbucket - ssh 脚本问题
【发布时间】:2016-02-03 06:27:36
【问题描述】:

关于使用 ssh 的 Bitbucket 指南提供了一个脚本,我已将其添加到 bashrc,但是当它运行时它会自动显示已连接,而不是请求密码。当我跑步时

ssh-add -l

我收到消息“代理没有身份。”

我在 Windows 上,我设置了我的 .ssh 目录,它包含配置、环境和 known_host 文件。此外,我在这里放置了一个 KEYS 目录,其中包含生成的 ssh 密钥。

环境和 known_host 已生成,但我自己创建了配置, 它仅包含以下内容

Host bitbucket.org
 IdentityFile ~/.ssh/KEYS/theMachine

不知道环境文件数据是什么意思,暂时不贴。

我所关注的指南位于此处:

https://confluence.atlassian.com/bitbucket/set-up-ssh-for-git-728138079.html

我已经完成了第 6 步,但我卡在第 4 步。

【问题讨论】:

    标签: git ssh version-control bitbucket


    【解决方案1】:

    您将密钥存储在不同的位置,因此 ssh-add 找不到它(它不会读取您的配置 - 教程不太好)。

    您应该将您的~/.ssh/KEYS/theMachine 移至~/.ssh/id_rsa。是的。并将~/.ssh/KEYS/theMachine.pub 移动到~/.ssh/id_rsa.pub。它会解决你的问题。


    替代解决方案是修改 ~/.bashrc 中的行

    /usr/bin/ssh-add
    

    /usr/bin/ssh-add ~/.ssh/KEYS/theMachine
    

    【讨论】:

      【解决方案2】:

      代理没有身份。

      更多信息请阅读For Unix, what are ssh-agent and ssh-add, and how do I use them?


      按照这些步骤开始并添加您的 ssh 密钥和代理。

      # start the ssh agent service
      eval $(ssh-agent)
      
      # your keys should now be automatically loaded from the ~/.ssh folder
      # but just in case to verify that they were loaded:
      ssh-add
      

      【讨论】:

      • 感谢您的回答,我收到的另一个答案有效,所以我接受了。但是你能解释一下这有什么作用以供将来参考吗?
      • ssh 代理有时会停止工作,因此 eval 只需重新启动它。当它重新启动时,它会从默认位置读取密钥,除非你给它不同的位置
      • ssh-agent 本身不应该停止工作,除非周围的东西坏了。如果代理不运行,它将写入Could not open a connection to your authentication agent.。这真的不是在回答问题。
      • 有时我必须使用 eval 来为服务加注星标。通常在 vm 图像上。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-03-20
      • 2018-01-16
      • 1970-01-01
      • 2014-12-29
      • 2018-03-29
      相关资源
      最近更新 更多