简体   繁体   English

Windows上通过SSH转发的Git克隆

[英]Git clone over SSH Forwarding with Windows

I would like to connect to my gitlab server from home but I am getting problems. 我想从家里连接到我的gitlab服务器,但遇到了问题。 How can I do this? 我怎样才能做到这一点?

Computer A <------------> Computer B <-----------------> Computer C (gitlab)

What I have so far: 到目前为止,我有:

  • I created a tunnel with Putty 我用腻子创建了一条隧道
    • (Session) Hostname: ComputerB-IP (会话)主机名:ComputerB-IP
    • (Session) Port: 22 (会话)端口:22
    • (Connection/Tunnels) L3333 ComputerC-IP:22 (连接/隧道)L3333计算机C-IP:22
  • I created a private key with Putty-keygen and added it to my account in gitlab 我用Putty-keygen创建了一个私钥,并将其添加到我在gitlab中的帐户中

What I can do: 我可以做什么:

  • I can connect with ssh to localhost:3333 which connects me to the gitlab server (Computer C). 我可以使用ssh连接到localhost:3333,该主机将我连接到gitlab服务器(计算机C)。 So I think the tunnel is working. 因此,我认为隧道正在运行。

What I can't do: 我不能做的:

  • When I clone a git repository with TortoiseGit I use the following url: git@localhost:3333:my/repo.git I get the following error: 当我用TortoiseGit克隆git存储库时,我使用以下网址: git@localhost:3333:my/repo.git我收到以下错误:

Cloning into 'C:\\Users\\xxxx\\Desktop\\EXCHANGE\\git-repo'... fatal: Could not read from remote repository. 克隆到'C:\\ Users \\ xxxx \\ Desktop \\ EXCHANGE \\ git-repo'...致命:无法从远程存储库读取。

Please make sure you have the correct access rights and the repository exists. 请确保您具有正确的访问权限,并且存储库存在。

git did not exit cleanly (exit code 128) (3531 ms @ 5/10/2016 2:53:26 PM) git没有干净退出(退出代码128)(3531 ms @ 5/10/2016 2:53:26 PM)

I load the private rsa key with TortoiseGit previous to the clone call... 我在克隆调用之前使用TortoiseGit加载了rsa私钥...

Any ideas? 有任何想法吗?

Set up a putty session and configure a different port (3333) there. 设置腻子会话并在那里配置其他端口(3333)。 This cannot be done in the clone URL. 无法在克隆URL中完成。 Then use the session name instead of localhost. 然后,使用会话名称代替localhost。

Btw. 顺便说一句。 you can also configure the tunnel within this session, so that it gets automatically set up for cloning/fetching/pulling. 您还可以在此会话中配置隧道,以便自动设置该隧道以进行克隆/提取/拉取。

See https://stackoverflow.com/a/29183147/3906760 参见https://stackoverflow.com/a/29183147/3906760

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM