stevejb
stevejb

Reputation: 2444

Running a git server with ssh and NAT

I have the following setup:

What I would like to do is access my gitlab vm from the outside world. What do I need to do so that I can have git-related ssh traffic forwarded to my VM (192.168.1.150), but normal ssh traffic to (192.168.1.140). Is this possible?

EDIT:

What I want to do is make sure that other clients on my home network interact with git in the same way. For example, I want to use stevejb-gitlab.example.com as my git server whether I am on my home network or not.

Upvotes: 1

Views: 1240

Answers (1)

Chris
Chris

Reputation: 137074

Add a second port forward.

For example, forward all traffic on port 22 to your regular server, but all traffic on port 2222 (or whatever you choose) to your GitLab VM. Then make sure to include port 2222 in your Git requests and you should be good to go:

git remote add home ssh://[email protected]:2222/project/repo.git

As an aside, you may want to change both ports away from the default SSH port of 22. This doesn't add a ton of security, but in my experience it has had a noticeable impact on brute force password attacks on my servers.

Upvotes: 1

Related Questions