Why can I still ssh into my Ubuntu machine using a password? This is the /etc/ssh/sshd_config
file of my Ubuntu 20.04 on ovh hosting (showing only non-commented lines for brevity):
Include /etc/ssh/sshd_config.d/*.conf
Port xxx
PermitRootLogin no
AllowUsers user1 user2
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys .ssh/authorized_keys2
PasswordAuthentication no
ChallengeResponseAuthentication no
UsePAM yes
X11Forwarding yes
PrintMotd no
AcceptEnv LANG LC_*
Subsystem sftp /usr/lib/openssh/sftp-server
The permissions of the relevant files seem to be OK:
$ stat -c %a /home/user1/.ssh/
700
$ stat -c %a /home/user1/.ssh/authorized_keys`
600
I have run sudo service ssh restart
and sudo service sshd restart
.
Why am I still able to log into my Ubuntu machine by password over ssh? I can login by user and password over ssh (PuTTY), it only asks for password. Both user1 and user2 have their key in .ssh home folder. What is missing?
I checked the include file:
-rw------- 1 root root 27 Dec 1 12:52 50-cloud-init.conf
...:/etc/ssh/sshd_config.d$ sudo cat 50-cloud-init.conf
PasswordAuthentication yes
so I guess that is the cause? However, wouldn’t my config overwrite this setting? since it is included above (line wise)?
sudo service sshd restart
or did you only restartssh
? These are setting for the sshd service (the ssh server) not the ssh service (ssh client).ssh
, andsshd
is just an alias (/etc/systemd/system/sshd.service -> /lib/systemd/system/ssh.service
) specified via the ssh.service file's[Install]
sectionman sshd_config
: "For eack keyword, the first obtained value will be used."