Ssh – Use different authentication methods for OpenSSH server depending on client IP

opensshssh

I'm sure this has been answered before, but I could not locate the answer with Google, and this search. I currently only allow shared key authentication for openssh server on my box. However, I would like to be able to use password auth, when I am connecting locally, via my internal (192.168.1.x) subnet.

Is it possible to use a per-host authentication method in OpenSSH? Thanks!

Best Answer

Use a Match directive in /etc/sshd_config.

PasswordAuthentication No
Match Address 192.168.1.0/24
    PasswordAuthentication yes

You can restrict this to a few users (who you trust not to choose terrible passwords), for better security.

PasswordAuthentication No
Match Address 192.168.1.0/24 User joe,bob
    PasswordAuthentication yes
Related Question