SSH隧道允许sshstream量:连接总是被拒绝

我可以访问两个服务器在工作。 服务器A托pipegit存储库,并在外部可见。 我想能够克隆到服务器A上托pipe的服务器B的存储库。

目前,我无法从服务器B SSH到服务器A.我假设防火墙阻止。

所以我试图创build一个SSH隧道后,我遇到的写作,但迄今无济于事。

从服务器A的shell:

$ ssh -L 1234:localhost:22 user@server_b 

这成功地login到服务器B.从那里我似乎无法做任何使用ssh

 $ ssh user@localhost $ user@localhost's password: <entered correctly> $ Permission denied, please try again. $ ssh user@localhost -p 1234 $ ssh: connect to host localhost port 1234: Connection refused 

试图克隆

 $ git clone ssh://user@localhost:1234/path/to/repo.git/ $ ssh: connect to host localhost port 1234: Connection refused $ fatal: The remote end hung up unexpectedly 

我的初始隧道命令是不正确的? 或者我可能需要让networkingpipe理员在防火墙上打开一些东西?

您需要使用-R而不是-L创build反向通道。

在本地机器上使用

 ssh -R 1234:server_a:22 user@server_b 

你会在server_b上得到一个shell。 如果你这样做

 ssh -p 1234 user@localhost 

在这个shell中,这将把你连接到server_a 22端口,通过本地机器传输。

之后,你的git clone命令应该可以工作。