我可以通过 ssh 访问服务器 A,从服务器 A 可以访问服务器 B,它运行 gitlabs 并包含我需要访问的存储库。当我通过 ssh 进入服务器 A 时,我可以git clone http://serverB/path/to/repo.git成功运行。使用ssh://或git://代替http://不起作用。(错误分别是“似乎不是 git 存储库”和“无法连接到 serverB”。)
如果我设置这样的隧道:
ssh username@serverA -L 3333:serverB:80 -N
Run Code Online (Sandbox Code Playgroud)
以下两次 git 克隆尝试失败:
git clone http://localhost:3333/path/to/repo.git
Run Code Online (Sandbox Code Playgroud)
失败:“致命:未找到存储库”
git clone localhost:3333/path/to/repo.git
Run Code Online (Sandbox Code Playgroud)
提示我输入 serverB 的密码,然后失败并显示“致命:3333/path/to/repo.git 似乎不是 git 存储库”。当然不是!我试图指定 localhost,端口 3333,显然被解释为 serverB 上的相对路径。
有没有办法来解决这个问题?这种方法有什么根本问题吗?