[英]Using git with SSH-key on Windows
I am connecting to my virtual machine with ssh like this: 我正在使用ssh这样连接到我的虚拟机:
ssh -i keyfile.key user@server.com
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存储库,但是我不知道如何在git中使用keyfile.key。
I am supposed to execute the command: 我应该执行命令:
git push live master
But I getting the error "permission denied (publickey)", so how do I specify the key? 但是我收到错误消息“权限被拒绝(公钥)”,那么如何指定密钥? I am on Windows 8.
我在Windows 8上。
You need to: 你需要:
use a, ~/.ssh/config
( check where %HOME%
is set , since you are on Windows). 使用
~/.ssh/config
(因为您在Windows上, 请检查%HOME%
的设置位置)。
The config file would look like (replace <hostkey>
by any string you want) 配置文件看起来像 (用任何所需的字符串替换
<hostkey>
)
Host <hostkey> HostName myserver User user IdentityFile C:\\path\\to\\.ssh\\keyfile.key IdentitiesOnly yes
change your remote url to one using the config Host key 使用Config Host键将远程URL更改为一个
git rmeote set-url list <hostkey>:myrepo
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.