在 Windows 上使用带有 SSH 密钥的 git [英] Using git with SSH-key on Windows
问题描述
我像这样使用 ssh 连接到我的虚拟机:
I am connecting to my virtual machine with ssh like this:
ssh -i keyfile.key user@server.com
我在要推送到的服务器上创建了一个 git 存储库,但我不知道应该如何将 keyfile.key 与 git 一起使用.
I have created a git repository on the server which I want to push to, but I do nott know how I should use the keyfile.key with git.
我应该执行命令:
git push live master
但我收到错误权限被拒绝(公钥)",那么我该如何指定密钥?我使用的是 Windows 8.
But I getting the error "permission denied (publickey)", so how do I specify the key? I am on Windows 8.
推荐答案
您需要:
使用一个,
~/.ssh/config
(检查%HOME%
已设置,因为您使用的是 Windows.
配置文件看起来像(用你想要的任何字符串替换
)
use a,
~/.ssh/config
(check where%HOME%
is set, since you are on Windows).
The config file would look like (replace<hostkey>
by any string you want)
Host <hostkey>
HostName myserver
User user
IdentityFile C:\path\to\.ssh\keyfile.key
IdentitiesOnly yes
使用配置主机键将您的远程 url 更改为 1
change your remote url to one using the config Host key
git rmeote set-url list <hostkey>:myrepo
这篇关于在 Windows 上使用带有 SSH 密钥的 git的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!