首先將設置應用到組,除了用戶名,然後將(其他)設置應用於用戶名。如果您不使用用戶用戶名的「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
用戶登錄