Forward ssh connection of single user

断了今生、忘了曾经 提交于 2019-12-12 05:58:44

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!