我刚刚安装了Git For Windows,并使用Cygwin通过SSH创建了我的SSH密钥。它似乎在命令行和Git For Windows GUI中工作正常,但现在我想要使用TortoiseGit。TortoiseGit默认使用类似Putty的SSH客户端,但明显GitHub只接受(open)SSH,并且我不知道该如何继续。我将进行一个干净的TortoiseGit安装,我已经安装了Cygwin和Git for Windows。
我刚刚安装了Git For Windows,并使用Cygwin通过SSH创建了我的SSH密钥。它似乎在命令行和Git For Windows GUI中工作正常,但现在我想要使用TortoiseGit。TortoiseGit默认使用类似Putty的SSH客户端,但明显GitHub只接受(open)SSH,并且我不知道该如何继续。我将进行一个干净的TortoiseGit安装,我已经安装了Cygwin和Git for Windows。
cd ~ ; echo "GIT_SSH = "c:/path/to/tortoiseplink.exe"" > .profile
,这样应该可以工作,但是最好进行干净的重新安装,并使用不带Tortoise Git或Plink的OpenSSH。 - Learath2C:\Documents and Settings\<user>\.ssh\
中 - 这是我的位置,与Git for Windows(卸载)是分离的。 - Philip Oakley使用本文所描述的方法:使用SSH密钥口令。
在Cygwin会话启动时只会询问一次口令。 !!! 退出Cygwin会话前别忘记杀死ssh-agent进程(使用ps找到进程PID并执行kill -9命令)。
我们为Cygwin使用独立的方法,因为某些原因Cygwin无法看到在Windows环境下外部启动的进程。
有用的链接: http://dogbiscuit.org/mdub/weblog/Tech/WindowsSshAgent
安装MsysGit。 安装TortoiseGit(安装过程中选择openssh而不是plink)。 !!! 检查系统变量。如果存在GIT_SSH变量,请将其删除。
转到TortoiseGit ->设置 ->常规。
将Git EXE路径设置为<MsysGit主目录>/bin。 将外部DLL路径设置为<MsysGit主目录>/mingw/bin。
转到TortoiseGit ->设置 ->网络。 将SSH客户端属性设置为<MsysGit主目录>/bin/ssh.exe。
定义系统变量SSH_AUTH_SOCKS=C:\temp.ssh-socket
启动cmd.exe并执行以下命令(由于我们安装了MsysGit,所有以下命令都可以在cmd中访问——<MsysGit>/bin已添加到系统PATH变量中):
# The following command is required to execute for avoiding an address already bind message when ssh-agen is not started yet but .ssh-socket exists after previous agent session
rm "%SSH_AUTH_SOCK%"
# Starting ssh-agent
ssh-agent -a "%SSH_AUTH_SOCK%"
# Adding our openssh key
ssh-add "%USERPROFILE%\.ssh\id_rsa"
# Type password for your key
就是这样。从那一刻起,您可以执行git push
,git pull
,而无需输入密码提示符,使用TortoiseGit和MsysGit。
当不再需要ssh-agent时,可以通过Windows任务管理器将其关闭。
git config --global user.name 'yourUser'
git config --global user.email 'youremail@domain.com'
git clone https://location/of/repo
yourUser
在这里粘贴您的PAS,而不是您的真实密码。
这个解决方案是由Anmol Jain提供的,对我来说非常完美。他发布了适用于Source Tree的解决方案,也适用于Tortoise Git。
步骤: