Ssh – Forward ssh for Git user to Git server

gitgitlabopensshsshsshd

It is surprisingly difficult to find information on this simple problem.

Like many people we run a gitlabs/gogs server on a remote instance. Currently it listens on port 10022. We also run ssh on that instance to administer the server. It listens on port 22.

We'd like the ssh server listening on port 22 to forward connections for Git@ ONLY to the Git server on 10022.

That way when people use Git locally, they won't have to manually specify the port of our remote Git server each time.

How can we do this?

Best Answer

I have never done that but maybe this does what you want:

You can put a Match block for the user git in sshd_config which contains ForceCommand. The forced command can be an ssh login to the real server. You can use public key authentication without passphrase so the users might not even notice this.

Related Question