大网数据广告活动
服务器运维问答

SSH gateway with all config on the gateway?

· 52CE 我爱测

I have a ubuntu server running some LXD containers - none of these have public IP's, but are exposed to the web by a reverse proxy for HTTP. These containers belong to different individuals and I would like to be able to allow th…

问题原文

原帖链接 · Sam · CC BY-SA 4.0

I have a ubuntu server running some LXD containers - none of these have public IP's, but are exposed to the web by a reverse proxy for HTTP.

These containers belong to different individuals and I would like to be able to allow them to login to the container via SSH. I don't want to allow users to be able to try passwords on containers other than their own one, And I don't want users to have to configure the SSH tunnel / gateway themselves.

So I'm wonderig if there's a way that I can set up an SSH gateway such that, based on the users key or username, the proxying is automated for them through the gateway.

This old article - http://quark.humbug.org.au/publications/ssh/ssh-tricks.html - seems to imply that something like this is possible: "The SSH gateway works by forcing a ssh to another host as a particular username, based on the ssh key."

However I can't find any other reading about it ... Is this something that can be done?

已采纳解答

原帖链接 · HBruijn · CC BY-SA 4.0

That article makes use of a relatively underused feature of the openssh and the ~/.ssh/authorized_keys file format - namely: the ability to configure options/restrictions that will be set when a particular keypair is used to log in.
One of those options is the command="/path/to/command [-o options]" that will ensure that instead of a normal interactive login shell a different, custom command will be executed.

By setting that custom command to command="ssh user@container" what will effectively happen is that when a session ssh login@host succeeds with a specific keypair, an ssh session will started that presents the password prompt (and access) to the user account on a specific container.

The easiest is that you set up a single account on your host for that.
You would request that every customer provides you with their public key.
When customers have multiple containers they will need one keypair per container.

You instruct all your customers to use their keypair to authenticate an log in to 1 account, for instance [email omitted]

In the home directory /home/access/.ssh/authorized_keys there will be one line for each customer/public_key

command="ssh user1@container1" ssh-rsa AAAAB5..base64_encoded_key_customer1... COMMENT
command="ssh user2@container2" ssh-rsa AAAAB5..base64_encoded_key_customer2... OTHER-COMMENT

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2019-02-07)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。