Dev*_*eve 7 git ssh proxy git-clone
我想从我公司的服务器克隆一个git存储库到我的个人电脑.从"外部"访问这些服务器的唯一方法是将每个ssh登录到"machine1"
ssh user@machine1.company.xy
Run Code Online (Sandbox Code Playgroud)
不幸的是,git没有安装在那台特定的机器上.所以git克隆就像
git clone ssh://user@machine1.company.xy/path/to/repo <local-repo-path>
Run Code Online (Sandbox Code Playgroud)
不行.我需要做的是在通过'machine1'登录网络后更改到安装了git的另一台机器'machine2'.因此,要使克隆工作,我将不得不执行一个命令
ssh machine2
Run Code Online (Sandbox Code Playgroud)
在实际执行git命令之前.有没有办法做到这一点?像预克隆钩子之类的东西可能吗?
有可能以某种方式将远程存储库打包到一个文件(补丁?),将该文件复制到本地计算机并从该文件克隆?
期待您的提示和建议!
bdo*_*lan 13
您可以通过配置ssh proxy命令来完成此操作.注意:这假设代理服务器上有netcat ; 您可以使用perl中的类似脚本替换netcat或其他任何需要的脚本.
添加以下内容~/.ssh/config
,根据需要创建它:
Host machine1
User yourusername
HostName machine1.yourcompany.com
Host machine2
User yourusername
ProxyCommand ssh machine1 nc %h %p
HostName machine2.internal.network
Run Code Online (Sandbox Code Playgroud)
现在你可以ssh machine2
,它会自动穿过machine1.这意味着使用git就像git clone ssh://machine2/path
.
也可以使用该git bundle
命令将存储库捆绑到单个文件中.但是,对于正确的ssh代理设置,这不是必需的.
归档时间: |
|
查看次数: |
16379 次 |
最近记录: |