Ssh – How to lock the own account from remote ssh login with password

authenticationkey-authenticationssh

I don't want to disable remote login with password altogether, but I want to make it so that my account is only accessible with key pair authentication (there are other users who wants to use passwords to log in). Is it possible to change this on a per-user basis, ideally without changing system settings?

And to make it clear, my account has sudo access, so I don't want to lock the password.

Best Answer

You can use the Match option in sshd_config

Match Introduces a conditional block. If all of the criteria on the Match line are satisfied, the keywords on the following lines override those set in the global section of the config file, until either another Match line or the end of the file.[1]

So, at the end of that file you could specify:

Match User yourusername
PasswordAuthentication no

See man 5 sshd_config for all of the available options.

[1] http://www.openbsd.org/cgi-bin/man.cgi?query=sshd_config&sektion=5

Related Question