[英]ssh authenticated git access at windows command prompt?
There are many fine instructions about how to work with git under windows using GitBash. 关于如何使用GitBash在Windows下使用git有很多很好的说明。
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. 我注意到,安装git时,它提供了“设置从Windows提示符下使用git的选项”,该选项将git放在Windows路径上。
Is there some way to set this up so that ssh authentication works? 有什么方法可以设置它以便ssh身份验证有效吗?
At the moment I get "permission denied (publickey)" when I try to do git commands that access the remote. 现在,当我尝试执行访问远程设备的git命令时,我收到“ permission否认(公钥)”。
(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. (编辑)我已经将%HOME%设置为指向我的Windows主目录,并且其中有一个.ssh文件夹,其ID文件在gitbash shell下工作。
I appreciate that the answer is likely "no, this is why GitBash exists". 我知道答案很可能是“不,这就是GitBash存在的原因”。 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? 如果答案为“否”,那会让您想知道为什么还要麻烦将git放在Windows路径上?
ssh access works fine from a regular DOS session. ssh访问可以在常规DOS会话中正常工作。
You only need to define C:\\Users\\YourAccount\\.ssh
and add your id_rsa
and id_rsa.pub
there. 您只需要定义
C:\\Users\\YourAccount\\.ssh
并在其中添加id_rsa
和id_rsa.pub
。
Launch your git session through git-cmd.bat
, which will define %HOME%
to your C:\\Users\\YourAccount
: that is what will make ssh work. 通过
git-cmd.bat
启动git会话,该会话将为您的C:\\Users\\YourAccount
定义%HOME%
:这将使ssh正常工作。
This should put your msysgit/bin installation in your PATH. 这应该将您的msysgit / bin安装放在PATH中。
I really recommend not installing through a msi (Microsoft Installer), but through a simple unzip of an archive ( portable version " PortableGit-xyz-preview201ymmdd.7z
" ) 我真的建议您不要通过msi(Microsoft安装程序)进行安装,而是通过压缩文件的简单解压缩( 便携式版本“
PortableGit-xyz-preview201ymmdd.7z
” )进行安装
And the OP GreenAsJade 's comment points out the fact that GIT_SSH
must point to plink.exe
. OP GreenAsJade的评论指出了
GIT_SSH
必须指向plink.exe
。
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. 如果在密钥生成过程中使用密码,则必须在加载ssh-agent并将密钥添加到代理后键入此密码。
Basically, the solution is: follow the instructions on this page: 基本上,解决方案是:按照此页面上的说明进行操作:
https://confluence.atlassian.com/bitbucket/set-up-ssh-for-git-728138079.html 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). 但是,.bashrc脚本将按预期工作(在git bash启动时加载身份)。
You can use then the "start-ssh-agent.cmd" script located on Git\\cmd folder. 然后,您可以使用Git \\ cmd文件夹中的“ start-ssh-agent.cmd”脚本。 It will open a Dos Prompt with the identity loaded and everything will work!
它将打开一个Dos Prompt,并加载了身份,一切正常!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.