2012-09-14 22 views
2

是否有可能獲得git的使用比「SSH」以外的東西作爲SSH程序以外的SSH(RSH)運輸? Rsync有一個用於此目的的-e選項,以及其他可以將rsh或ssh用作傳輸的接口。的特定用途的情況下,我有被鏈接經由堡壘主機SSH連接,如直接ssh訪問從中我克隆宿主/牽引不是由防火牆。如何獲得git的使用比「SSH」

我想出迄今最好的解決方案是創建一個名爲它「SSH」一個可執行文件的目錄,並把該目錄在我的道路的開始。 「ssh」文件的內容是:

#!/bin/sh 
# If we were being clever we'd look at where we were and just snip that 
# off the path. 
export PATH=/bin:/usr/bin:/sbin:/usr/sbin 
exec ssh bastion.example.org ssh "[email protected]" 

這可行,但該方法有許多缺點。

注意,GIT_SSH環境變量沒有做什麼,我以後,你還必須創建一個腳本和引用。而與rysnc的-e選項我可以做

rsync -e 'ssh -K bastion.example.org ssh' ... 

回答

2

,而不是試圖配置GIT中使用其他程序,您可以配置SSH本身:

~/.ssh/config文件,添加一個新的Host部分

Host git.example.org 
    Username myusername 
    ProxyCommand ssh bastion.example.org "nc git.example.org 22" 

然後,你只需要遠程指向「git.example.org」主持人。

另外,如果您正在使用OpenSSH> = 5.4,並且不希望在服務器上的netcat的依賴,你可以使用SSH的netcat mode代替:

Host git.example.org 
    Username myusername 
    ProxyCommand ssh bastion.example.org -W "git.example.org:22"