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

标签 git ssh ssh-keys

在这些命令之后,

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/

相关文章:

linux - scp2通过批处理脚本从Linux到Windows,*.*文件掩码问题

linux - 远程 X 登录 Linux

git - 尽管存在 ssh key ,但 Gitlab Ci 上的 "Host key verification failed"

git - 无法使用 git 配置文件进行 ssh

git - 如何判断删除行的作者是谁?

eclipse - 使用 TFS 插件从 RSA 9.1 访问 GIT 存储库时出现内部错误

java - Akka 输入流处理

linux - Ansible服务器无法连接aws云主机

两个本地存储库之间的git推送错误

git - 如何在 Jenkins 中通过 ssh-agent 在 Windows 上直接使用 git