[本机为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, …Run Code Online (Sandbox Code Playgroud)