gpt4 book ai didi

在 Windows 上使用 SSH 私钥进行 Git 推送

转载 作者:行者123 更新时间:2023-12-02 14:10:29 25 4
gpt4 key购买 nike

在这些命令之后,

git remote add origin server:<repo>.git
git push origin master

我需要输入密码。但我只想使用我的私有(private) ssh key 对服务器进行身份验证。例如,我可以使用该私钥连接到服务器,但我不知道如何使用它推送 git 存储库。

我的公钥ofc添加到服务器上的授权 key 。

最佳答案

您的服务器需要支持 ssh 或 gitosis为了做到这一点。吉托西斯:

在你的 cae 中你提到你有 ssh 连接所以你只需要使用 ssh 协议(protocol)设置远程

git remote set-url origin ssh://......

# or
git remote set-url origin git@...

如何为git配置ssh key 路径

  • 打开终端窗口。
  • 编辑~/.ssh/config 文件。
  • 如果您没有配置文件,请创建一个。
  • 为每个身份组合添加一个别名,例如:

    Host <Host Name>
    HostName AAAAAAA.org
    IdentityFile ~/.ssh/<key for the given host>

    Host <Host1 Name>
    HostName BBBBB.org
    IdentityFile ~/.ssh/<host 2 key>

关于在 Windows 上使用 SSH 私钥进行 Git 推送,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53793898/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com