I'm using NixOS. Here's my SSHd config:
services.openssh.enable = true;
services.openssh.passwordAuthentication = false;
services.openssh.challengeResponseAuthentication = false;
services.openssh.permitRootLogin = "no";
services.openssh.extraConfig = ''
Match User dropbox
PasswordAuthentication yes
'';
As you can see, I'm disallowing SSH login with passwords, but as an exception, allowing it for the user dropbox
. This Nix syntax results into following sshd_config:
UsePAM yes
AddressFamily any
Port 22
X11Forwarding no
Subsystem sftp /nix/store/6fkb47ri4xndlpszjrbw8ggd3vmb6in7-openssh-8.1p1/libexec/sftp-server
PermitRootLogin no
GatewayPorts no
PasswordAuthentication no
ChallengeResponseAuthentication no
PrintMotd no # handled by pam_motd
AuthorizedKeysFile .ssh/authorized_keys .ssh/authorized_keys2 /etc/ssh/authorized_keys.d/%u
HostKey /etc/ssh/ssh_host_rsa_key
HostKey /etc/ssh/ssh_host_ed25519_key
KexAlgorithms [email protected],diffie-hellman-group-exchange-sha256
Ciphers [email protected],[email protected],[email protected],aes256-ctr,aes192-ctr,aes128-ctr
MACs [email protected],[email protected],[email protected],hmac-sha2-512,hmac-sha2-256,[email protected]
LogLevel VERBOSE
UseDNS no
Match User dropbox
PasswordAuthentication yes
On the surface, this seems to work. It doesn't allow password login for other users, but allows for dropbox
. This is with ssh -v dropbox@poi
:
debug1: Next authentication method: password
dropbox@poi's password:
debug1: Authentications that can continue: publickey,password
Permission denied, please try again.
However, it doesn't accept dropbox
's password. It's the exact same (simple, three letter toy password) password that allows me to log in, so the password isn't wrong. I've even copy-pasted it to avoid the caps-lock trap. The same password that allows login doesn't allow SSH login.
HOWEVER, if I set passwordAuthentication
allowed for ALL users, then dropbox
magically is able to log in with it's password. I've verified that the Match
part is always in the end of sshd_config
, so this is not about ordering issues.
I've never heard this kind of behaviour. Is there any tricks that would allow me to debug this?