问题
I have a server running a gogs docker container with a sshd running. The hosts sshd listens on port 22. To keep things easy for the users I want git to listen on port 22 aswell. Therefore I try to forward the ssh connections of the user "git" to the sshd of the docker container without handling it in the host ssh daemon.
In contrast to http there is nothing like a url in ssh, hence it's not possible to forward the connection in a proxy based on a subdomain.
Any other suggestions?
回答1:
In your .ssh/config, you can put :
Host mygogs
Hostname gogscontainerip
User git
ProxyCommand ssh user@gogshostip "nc %h 22"
then you can try it by
git clone mygogs:/path/to/your/repo.git
You can also add your key in .ssh/authorized_keys
in the homefolder of git on gogscontainer and your one on gogshost then you won't be asked for your pass if you add to the config below :
ForwardAgent yes
来源:https://stackoverflow.com/questions/38704418/forward-ssh-connection-of-single-user