单用户正向ssh连接 [英] Forward ssh connection of single user

查看:119
本文介绍了单用户正向ssh连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一台运行goss docker的gogs docker容器的服务器. 主机sshd侦听端口22. 为了使用户易于使用,我希望git也可以在端口22上监听. 因此,我尝试将用户"git"的ssh连接转发到docker容器的sshd,而不在主机ssh守护进程中对其进行处理.

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.

与http相比,ssh中没有类似url的内容,因此无法在基于子域的代理中转发连接.

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.

还有其他建议吗?

推荐答案

在.ssh/config中,您可以输入:

In your .ssh/config, you can put :

Host mygogs
Hostname gogscontainerip
User git
ProxyCommand ssh user@gogshostip "nc %h 22"

然后您可以尝试通过

git clone mygogs:/path/to/your/repo.git

您还可以将密钥添加到gogscontainer上git的homefolder的.ssh/authorized_keys中,以及您在gogshost上的密钥中,如果您将密码添加到以下配置中,则不会要求您通过密码:

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

这篇关于单用户正向ssh连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆