在 Windows 上使用 git 和 SSH 密钥
Using git with SSH-key on Windows
我像这样使用 ssh 连接到我的虚拟机:
ssh -i keyfile.key user@server.com
我在我想推送到的服务器上创建了一个 git 存储库,但我不知道如何将 keyfile.key 与 git 一起使用。
我应该执行命令:
git push live master
但我收到错误 "permission denied (publickey)",那么如何指定密钥?我在 Windows 8.
您需要:
使用一个,~/.ssh/config
(check 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
我像这样使用 ssh 连接到我的虚拟机:
ssh -i keyfile.key user@server.com
我在我想推送到的服务器上创建了一个 git 存储库,但我不知道如何将 keyfile.key 与 git 一起使用。
我应该执行命令:
git push live master
但我收到错误 "permission denied (publickey)",那么如何指定密钥?我在 Windows 8.
您需要:
使用一个,
~/.ssh/config
(check 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