在Windows上用SSH连接 [英] Git with SSH on Windows
问题描述
我已经通过由Tim Davis提供的优秀指南,这是关于配置Git以在Windows下使用SSH以生成Git服务器以便为我的DVCS创建主要位置的指南。
我正在为我的项目创建一个克隆。我已经完成了所有步骤直到这一点,但我一直从TortoiseGit得到这个:
git.exe clone -v ssh://Administrator@127.0.0.1:22 / SSH / Home / administrator / myapp.gitE:\GitTest\myapp
bash:Administrator@127.0.0.1:command未找到
在E:/GitTest/myapp/.git/
中初始化的空Git存储库致命:远程端意外挂起
成功
并没有任何东西被克隆。
BTW: TortoisePLink
就在这个消息出现之前出现并问我:登录为:
(我认为这个信息是在命令中给出的,即:<$ c $ b> Administrator @ blahblah 。
我的home变量设置为正确的位置:
从Git Bash shell: / p>
echo $ HOME
/ c / SSH / home /管理员
我也试过使用Putty的plink而不是 TortoisePLink
Git's和 TortoiseGit
的安装)。这次错误被缩小为:
git.exe clone -vssh://Administrator@127.0.0.1: 22 / c:/ SSH / Home / admin / myapp.gitE: $ b fatal:远端意外挂断
I在遇到明显的答案之前,与这个问题进行了几个小时的斗争。我遇到的问题是我在生成密钥和使用git时使用了不同的ssh实现。
我使用命令提示符中的ssh-keygen生成我的键,但是当我尝试git clone ssh:// ...时,我得到了与您相同的结果,提示输入密码并输入消息致命:远程端意外挂断。
通过执行Windowswhere命令确定哪些ssh窗口正在使用。
C: \ where ssh
C:\程序文件(x86)\Git\bin\ssh.exe
第二行告诉你哪一个确切的程序将被执行。
接下来,你需要确定git正在使用哪个ssh。通过以下方式查找:
C:\ set GIT_SSH
GIT_SSH = C:\程序文件\TortoiseSVN\\ \\ bin\TortoisePlink.exe
现在你看到了这个问题。
若要更正此问题,只需执行:
C:\ set GIT_SSH = C:\Program文件(x86)\Git\bin\ssh.exe
检查是否应用更改:
C:\ set GIT_SSH
GIT_SSH = C:\ Program Files(x86)\Git\\ \\ bin \ssh.exe
现在git将能够使用您之前生成的密钥。
这个修正目前仅适用于当前窗口。要完全修复它,您需要更改环境变量。
$ b
- 打开Windows资源管理器
- 点击计算机并选择属性
- 单击左侧的高级系统设置链接
- 单击环境变量...按钮
- 在系统变量部分选择GIT_SSH变量并按下Edit ...按钮
- 更新变量值。
- 按下OK关闭所有窗口
现在您打开的任何命令窗口都将具有正确的设置。
希望这有助于。
I've went through the excellent guide provided by Tim Davis which is about configuring Git to work with SSH under Windows in order to produce a Git Server in order to have a main place for my DVCS.
I am in the process of creating a clone for my project. I’ve went through all the steps till this point, but I keep getting this from TortoiseGit:
git.exe clone -v "ssh://Administrator@127.0.0.1:22/SSH/Home/administrator/myapp.git" "E:\GitTest\myapp"
bash: Administrator@127.0.0.1: command not found
Initialized empty Git repository in E:/GitTest/myapp/.git/
fatal: The remote end hung up unexpectedly
Success
and nothing gets cloned.
BTW: The TortoisePLink
comes up just before this message appears and asks me: "login as:
" ( I thought that this info is given in the command, i.e: Administrator@blahblah
.
My home variable is set to the correct place: From a Git Bash shell:
echo $HOME
/c/SSH/home/Administrator
I’ve also tried using Putty’s plink instead of TortoisePLink
(in both Git’s and TortoiseGit
’s installation). This time the error was narrowed down to:
git.exe clone -v "ssh://Administrator@127.0.0.1:22/c:/SSH/Home/administrator/myapp.git" "E:\GitTest\myapp"
Initialized empty Git repository in E:/GitTest/myapp/.git/
fatal: The remote end hung up unexpectedly
I fought with this problem for a few hours before stumbling on the obvious answer. The problem I had was I was using different ssh implementations between when I generated my keys and when I used git.
I used ssh-keygen from the command prompt to generate my keys and but when I tried "git clone ssh://..." I got the same results as you, a prompt for the password and the message "fatal: The remote end hung up unexpectedly".
Determine which ssh windows is using by executing the Windows "where" command.
C:\where ssh
C:\Program Files (x86)\Git\bin\ssh.exe
The second line tells you which exact program will be executed.
Next you need to determine which ssh that git is using. Find this by:
C:\set GIT_SSH
GIT_SSH=C:\Program Files\TortoiseSVN\bin\TortoisePlink.exe
And now you see the problem.
To correct this simply execute:
C:\set GIT_SSH=C:\Program Files (x86)\Git\bin\ssh.exe
To check if changes are applied:
C:\set GIT_SSH
GIT_SSH=C:\Program Files (x86)\Git\bin\ssh.exe
Now git will be able to use the keys that you generated earlier.
This fix is so far only for the current window. To fix it completely you need to change your environment variable.
- Open Windows explorer
- Right-click Computer and select Properties
- Click Advanced System Settings link on the left
- Click the Environment Variables... button
- In the system variables section select the GIT_SSH variable and press the Edit... button
- Update the variable value.
- Press OK to close all windows
Now any future command windows you open will have the correct settings.
Hope this helps.
这篇关于在Windows上用SSH连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!