I have a user on my linux server which is used for proxy. Currently the shell access and a lot of other features are disabled and the following command will be used on it:
ssh proxy-user@server -D 1080 -N
However recently I decided to put a limit on the number of simultaneous connections.
I've tried limits.conf
and MaxSessions
, but none of them can deal with the ssh -N
argument. They won't count these types of connections for the limit.
Is there anyway for me to limit the number of connections that are only using port forwarding (using the -N
argument)?
Notes:
- No I can't use a socks server such as dante
- I can't limit the total number of connections for all the users because I don't want to apply the limit for other users
- Here is the current limitations for the proxy user:
Match User proxy-user
AllowTcpForwarding yes
X11Forwarding no
PermitTunnel no
GatewayPorts no
AllowAgentForwarding no
PasswordAuthentication yes
ForceCommand echo 'This account can only be used for socks proxy'
AllowTcpForwarding
directive but there is nothing to control the number of connections when that is allowed.