ssh authenticated git access at windows command pr

2019-01-23 08:35发布

There are many fine instructions about how to work with git under windows using GitBash.

I note that when git is installed, it offers the option of "set up for using git from the windows prompt", which puts git on the windows path.

Is there some way to set this up so that ssh authentication works?

At the moment I get "permission denied (publickey)" when I try to do git commands that access the remote.

(edit) I have set %HOME% to point to my Windows home directory, and there is a .ssh folder in there with id files that work under a gitbash shell.

I appreciate that the answer is likely "no, this is why GitBash exists". But - it would be good to know for sure.

If the answer is "no" it kinda makes you wonder why you would bother putting git on your windows path?

标签: windows git ssh
2条回答
淡お忘
2楼-- · 2019-01-23 08:58

Well, maybe I have a process that seems to work.

If you use a passphrase during the generation of the keys, you'll have to type this passphrase after loading an ssh-agent and add the key to the agent.

Basically, the solution is: follow the instructions on this page:

https://confluence.atlassian.com/bitbucket/set-up-ssh-for-git-728138079.html

BUT, during the generation of the keys DO NOT TYPE A PASSPHRASE.

Obviously, it's 'weaker' from a security point of view.

But, the .bashrc script will work as expected (loading the identity on git bash startup).

You can use then the "start-ssh-agent.cmd" script located on Git\cmd folder. It will open a Dos Prompt with the identity loaded and everything will work!

查看更多
Explosion°爆炸
3楼-- · 2019-01-23 09:17

ssh access works fine from a regular DOS session.
You only need to define C:\Users\YourAccount\.ssh and add your id_rsa and id_rsa.pub there.

Launch your git session through git-cmd.bat, which will define %HOME% to your C:\Users\YourAccount: that is what will make ssh work.

This should put your msysgit/bin installation in your PATH.

I really recommend not installing through a msi (Microsoft Installer), but through a simple unzip of an archive (portable version "PortableGit-x.y.z-preview201ymmdd.7z")

And the OP GreenAsJade's comment points out the fact that GIT_SSH must point to plink.exe.

查看更多
登录 后发表回答