首先将设置应用于组,不包括用户名,然后将(其他)设置应用于用户名。如果您不对用户用户名使用“ForceCommand”设置,则不会应用。
Match Group groupname User !username
ChrootDirectory /srv/ftp
ForceCommand internal-sftp
Match User username
PasswordAuthentication yes
另一个示例是,如果用户从不同的 IP 地址登录,您可能需要不同的设置
#all users except username1 and username2 default to sftp
Match User *,!username1,!username2
PasswordAuthentication yes
AllowTCPForwarding no
X11Forwarding no
ForceCommand internal-sftp -f LOCAL0 -l INFO
#normal ssh allowed for users username1 and username2 from the local network
Match User username1,username2 Address 192.168.0.0/16
PasswordAuthentication yes
#users username1 and username2 not allowed from other networks
Match User username1,username2 Address *,!192.168.0.0/16
PasswordAuthentication yes
AllowTCPForwarding no
X11Forwarding no
ForceCommand /usr/sbin/nologin