kfu*_*uji 2 security ubuntu ssh configuration forwarding
[本机为192.168.80.125]
允许所有基本访问的普通 SSH 规则:
AllowUsers user1
PubkeyAuthentication yes
PasswordAuthentication no
AllowTcpForwarding yes
UsePAM no
Run Code Online (Sandbox Code Playgroud)
匹配组测试
AllowUsers user2@IP1 user2@IP2 user2@IP3 user2@IP4
PubkeyAuthentication yes
PasswordAuthentication yes
AllowTcpForwarding yes
PermitOpen 192.168.80.100:80
PermitOpen 192.168.80.125:443
AllowAgentForwarding no
Run Code Online (Sandbox Code Playgroud)
当我以 user2 身份从 IP1 连接到 sshd 时,我可以使用 PuTTY 打开隧道:
本地S:IP1:8080 远程D:192.168.80.100:80
本地源:IP1:8443 远程目标:192.168.80.125:443
我打开浏览器并浏览到 localhost:8080 我得到连接重置。我打开浏览器并浏览到 localhost:8443 我得到连接重置。
我检查 SSH 日志:
192.168.80.125 authlog: Received request to connect to host 192.168.80.100 port 80, but the request was denied.
192.168.80.125 authlog: Received request to connect to host 192.168.80.125 port 443, but the request was denied.]
Event Log: Opening connection to 192.168.80.125:443 for forwarding from [::1]:3585
Outgoing packet : (SSH2_MSG_CHANNEL_OPEN)
Incoming packet : (SSH2_MSG_CHANNEL_OPEN_FAILURE)
Event Log: Forwarded connection refused by server: Administratively prohibited [open failed]
OpenSSH_7.5p1 Ubuntu-10ubuntu0.1, OpenSSL 1.0.2g 1 Mar 2016
Run Code Online (Sandbox Code Playgroud)
当使用 SSH 作为 user1 和 pubkey/etc 时,我可以成功访问 192.168.80.125:80 / 192.168.80.125:443 处的资源,并且 TCP 转发对任何内容都可以正常工作。
我首先进行了 PermitOpen 设置,这很有效。然后我添加了 user2@ 限制,这就是打破这个问题的原因。
有一个更好的方法吗?我想确保 user2 只能通过隧道连接到指定的资源,并且只能从指定的 IP 登录。
我还注意到,当我以 user2 身份登录并切换到 user1 时,转发规则仍然基于 user2。
小智 5
嗯,这很尴尬。显然我的 PermitOpen 语法不正确。
我发现,如果列出多行 PermitOpen,则只有第一行实际上处于活动状态。
正确的语法:
PermitOpen <IP>:<port> <IP>:<port> <IP>:<port>......等等,在一条线上。
| 归档时间: |
|
| 查看次数: |
1829 次 |
| 最近记录: |