Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
960 views
in Technique[技术] by (71.8m points)

linux - Git with double SSH

I have: local, server1, server2.

I have Git repository on server2. But I can't connect with it. I can connect to server1 with SSH and then connect to server2 with SSH.

How can I push commits to server2 with double SSH? Is it possible?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Have a look at ssh's ProxyCommand. By adding a section into your ssh config file like

Host server2 ProxyCommand ssh -q server1 nc -q0 %h 22

you should be able to use git with a repo an server2. Note: This requires nc being available on server1.

This solution makes accessing server2 through ssh, e.g. with git, transparent as if it was directly accessible.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
...