Assumindo que é uma versão moderna do sshd, o / etc / ssh / sshd_config suporta o Match
e PermitOpen
diretivas, que podem ser combinadas para restringir os destinos especificados pelos clientes definindo as opções LocalForward
PermitOpen
Specifies the destinations to which TCP port forwarding is permitted. The forwarding specification must be one of the following forms:PermitOpen host:port PermitOpen IPv4_addr:port PermitOpen [IPv6_addr]:port
Multiple forwards may be specified by separating them with whites- pace. An argument of “any” can be used to remove all restrictions and permit any forwarding requests. By default all port forwarding requests are permitted. https://www.freebsd.org/cgi/man.cgi?sshd_config(5)
Então, algo assim deveria funcionar ...
Match User client_a
PermitOpen none
PermitOpen 192.168.10.2:22
Match User client_b
PermitOpen none
PermitOpen 192.168.11.2:22
Não tenho 100% de certeza sobre a ordenação dos PermitOpens .. ( By
default all port forwarding requests are permitted.
), portanto, talvez seja necessário estorná-los ou adicionar um Permit none
no ponto apropriado para bloquear encaminhamentos não correspondentes.
Ou possivelmente assim;
Match User client_a
PermitOpen 192.168.10.2:22
Match User client_b
PermitOpen 192.168.11.2:22
Match User client_a client_b
PermitOpen none