【问题标题】:Using git with SSH-key on Windows在 Windows 上使用带有 SSH 密钥的 git
【发布时间】:2015-09-11 06:38:00
【问题描述】:

我正在使用 ssh 连接到我的虚拟机,如下所示:

ssh -i keyfile.key user@server.com

我在要推送到的服务器上创建了一个 git 存储库,但我不知道如何将 keyfile.key 与 git 一起使用。

我应该执行命令:

git push live master

但我收到错误“权限被拒绝(公钥)”,那么如何指定密钥?我在 Windows 8 上。

【问题讨论】:

标签: windows git ssh


【解决方案1】:

你需要:

  • 使用~/.ssh/configcheck where %HOME% is set,因为您使用的是 Windows)。
    配置文件would look like(用你想要的任何字符串替换<hostkey>

    Host <hostkey>
      HostName myserver
      User user
      IdentityFile C:\path\to\.ssh\keyfile.key
      IdentitiesOnly yes
    
  • 使用配置主机密钥将您的远程 url 更改为一个

    git rmeote set-url list <hostkey>:myrepo
    

【讨论】:

    猜你喜欢
    • 2023-01-05
    • 1970-01-01
    • 2021-04-07
    • 1970-01-01
    • 2016-09-25
    • 1970-01-01
    • 2015-03-26
    • 1970-01-01
    • 2021-06-06
    相关资源
    最近更新 更多