I need to forbid ssh access (except localhost) for specified user.
ssh localhost should work.
ssh hostname from outside should not work for that user.
All other users should work as usual.
Basically these directives take a list of user patterns in the
For the simple case of just allowing a specific user from
This will implicitly deny any user from anywhere that isn't
How about if you force public key authentication for the specific user, and then restrict his public key with a
To force a specific user to use public key authentication:
And then in the authorized keys file configure his key like this:
You can read more about
You could use PAM (UsePAM in sshd_config) and add
to the PAM configuration for ssh.
Then you can define access policies in