【问题标题】:Switching Git to use SSH切换 Git 以使用 SSH
【发布时间】:2017-02-07 04:43:00
【问题描述】:

我设置了一个 SSH 密钥并将其添加到 Git 服务器。即使这样,在我的命令行中使用 Git 时,它仍然使用用户名和密码进行身份验证。是否有任何命令可以更改我的身份验证机制。

【问题讨论】:

    标签: git github ssh


    【解决方案1】:

    我相信您正在寻找凭证助手。在此处查看 git 文档:https://www.kernel.org/pub/software/scm/git/docs/v1.7.9/gitcredentials.html

    我的猜测是git config --global credential.helper cache 会成功。

    如果你在 Mac 上使用自制软件安装了 git,你可以使用这个:git config --global credential.helper osxkeychain

    这里还有一个堆栈溢出问题,其答案更深入地了解了 git 凭据:Is there a way to skip password typing when using https:// on GitHub?

    希望这会有所帮助!

    【讨论】:

      【解决方案2】:

      您是否使用 git 协议设置了远程分支 URL?

      你可以设置

      git remote set-url origin [SSH 协议 URL]

      SSH 协议 URL 看起来像 git@github.com:torvalds/linux.git

      【讨论】:

      • 其实就是一个SSH URL。 git 协议 URL 将以 git:// 开头。见git-fetch(1)
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-09-07
      • 1970-01-01
      • 2021-01-06
      • 2011-04-15
      • 2014-10-30
      • 2021-12-05
      相关资源
      最近更新 更多