【问题标题】:Git push using SSH private key on Windows在 Windows 上使用 SSH 私钥进行 Git 推送
【发布时间】:2019-05-16 13:28:08
【问题描述】:

在这些命令之后,

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

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

我的公钥 ofc 被添加到服务器上的授权密钥中。

【问题讨论】:

  • 你的 SSH 密钥是否使用密码?

标签: git ssh ssh-keys


【解决方案1】:

您的服务器需要支持 ssh 或 gitosis 才能执行此操作。 甲状腺肿:

在您的 cae 中,您提到您确实有 ssh 连接,因此您只需使用 ssh 协议设置远程

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

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

如何为 git 配置 ssh 密钥路径

  • 打开一个终端窗口。
  • 编辑~/.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>
    

【讨论】:

  • 我认为问题不是来自服务器,我认为是来自客户端。我觉得 git 不知道要使用的私钥在哪里。在尝试了你所说的之后,我收到了这条消息:“请确保你有正确的访问权限并且存储库存在。”
  • 更新答案并添加代码 - 如何为 git 映射 ssh 密钥
  • 嗨,我觉得它越来越好了。但是我有一个新的问题消息:(加载密钥“privateKey.ppk”:格式无效)。
猜你喜欢
  • 2013-08-26
  • 2014-12-26
  • 2023-03-24
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多