Your problem is partly that there is, as far as I know, no way to use a conditional Match
block to unset the ForceCommand
when that is set as a global default or set by another Match conditional.
So you can't do:
# /etc/ssh/sshd_config
# global config ...
# Enable the internal SFTP server and restrict all users to only SFTP
Subsystem sftp internal-sftp
ForceCommand internal-sftp
ChrootDirectory /shared
# ...
# Override and remove the ForceCommand sftp-only restriction
# for users in the server_admins group
Match group server_admins
ChrootDirectory none <=== this does exist
ForceCommand none <=== this does NOT exist
You solve that by implementing a different strategy: don't set the ForceCommand
as default, keep the defaults somehwat relaxed and then create a slightly more complicated Match
block with a negated pattern to make it apply to everybody (*
), except the members of server_admins
and there you override the defaults and add restrictions :
# /etc/ssh/sshd_config
# ...
# your current global config
#
# Enable the internal sftp server but do not set the ForceCommand
Subsystem sftp internal-sftp
# ...
# Everybody except members of the server_admins group are restricted to SFTP
Match group !server_admins,*
ForceCommand internal-sftp
ChrootDirectory /shared
X11Forwarding no
AllowTcpForwarding no
And similar to match the members of server_ftp-only
that are not also a member of server_admins
Match group !server_admins,server_ftp-only
ForceCommand internal-sftp
...