加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

unix – 允许用户设置SSH隧道,但没有其他

发布时间:2020-12-15 16:49:09 所属栏目:安全 来源:网络整理
导读:我想允许用户设置到特定端口(例如5000)上的特定计算机的SSH隧道,但我想尽可能限制此用户。 (认证将使用公共/私人密钥对)。 我知道我需要编辑相关的?/ .ssh / authorized_keys文件,但我不知道什么内容放在那里(除了公共密钥)。 在Ubuntu 11.10,我发现我可
我想允许用户设置到特定端口(例如5000)上的特定计算机的SSH隧道,但我想尽可能限制此用户。 (认证将使用公共/私人密钥对)。

我知道我需要编辑相关的?/ .ssh / authorized_keys文件,但我不知道什么内容放在那里(除了公共密钥)。

在Ubuntu 11.10,我发现我可以阻止ssh命令,发送带和不带-T,并阻止scp复制,同时允许端口转发通过。

具体来说,我有一个redis服务器上的“somehost”绑定到localhost:6379,我希望通过ssh通道安全地共享到其他主机有密钥文件,并将ssh与:

$ ssh -i keyfile.rsa -T -N -L 16379:localhost:6379 someuser@somehost

这将导致redis服务器上的“localhost”端口6379“somehost”在执行ssh命令的主机上本地显示,重新映射到“localhost”端口16379。

在远程“somehost”这里是我用于authorized_keys:

cat .ssh/authorized_keys   (portions redacted)

no-pty,no-X11-forwarding,permitopen="localhost:6379",command="/bin/echo do-not-send-commands" ssh-rsa rsa-public-key-code-goes-here keyuser@keyhost

no-pty启动了大多数想要打开终端的ssh尝试。

permitopen解释允许转发哪些端口,在这种情况下端口6379是我要转发的redis服务器端口。

如果有人或某物设法通过ssh -T或其他方式向主机发送命令,则command =“/ bin / echo do-not-send-commands”回显“do-not-send-commands”。

从最近的Ubuntu man sshd,authorized_keys /命令描述如下:

command=”command”
Specifies that the command is executed whenever this key is used
for authentication. The command supplied by the user (if any) is
ignored.

尝试使用scp安全文件复制也将失败,回声“do-not-send-commands”我发现sftp也失败与此配置。

我认为受限壳建议,在一些以前的答案,也是一个好主意。此外,我同意这里详述的一切可以通过读取“man sshd”并在其中搜索“authorized_keys”来确定,

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读