No Password SSH for special user (not root)

jaytee129

Member
Jun 16, 2022
144
10
23
Not long ago I was able to set up a user with no password logins through SSH, and that user's only role was to shutdown proxmox from a WIndows VM.

On a new install am trying the same SSH + no password user way of executing a shutdown from Windows VM but am getting stuck getting the no password part working can't figure out why.

First off, SSH works fine using putty for root, i.e. no password needed when I use putty and set login as root

Code:
Using username "root".
Authenticating with public key "rsa-key-20220720"
Linux thibworldpx3 5.15.39-1-pve #1 SMP PVE 5.15.39-1 (Wed, 22 Jun 2022 17:22:00 +0200) x86_64

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Wed Jul 20 14:31:21 2022 from 192.168.2.2
root@thibworldpx3:~#


But when I try to ssh with putty using login of 'sduser', I get this:

Code:
Using username "sduser".

Server refused our key
sduser@192.168.2.254's password:

PLUS I have no password for sduser:

Code:
passwd -S sduser
sduser NP 07/20/2022 0 99999 7 -1

AND sduser has been added to sudoers file using the line

Code:
sduser  ALL=(root) NOPASSWD: /usr/sbin/shutdown

Also tried the following syntax (and others) as I read different posts and got warnings from visudo about the syntax for that line

Code:
sduser  ALL=(root) NOPASSWD /usr/sbin/shutdown

Code:
sduser  ALL=(root) NOPASSWD:/usr/sbin/shutdown

Why is SSH asking for a password?

Same key pair for both has been copied to ~/.ssh/authorized_keys for both users (about 3 times now for sduser in case of typo or something), All on one line with CR at the end, like this (though I've changed it so I'm not posting the actual key):

Code:
root@thibworldpx3:/home/sduser/.ssh# more auth*
ssh-rsa  AAAAB3NzaC1yc2EAAAADAQABAAABAQCYsBC/CA9tAbqquYyrJYQ6sqTehJDPOridmiTU2oHIGqM9blahblahblahblahHuvc0Bmnaa19mYQjVmEwkwwEk+CRdTlQU6WIj2I+MpsWsTKPo6MBj4rFkWnQo8atAb1vU7Y+Va1p4v1as5AyOhH3tlniOyjgYTWX6aXdmz3Rm/fJS/6aTBNRlHrJfcQluchzpPca5XgfN+aT rsa-key-20220720

root@thibworldpx3:/home/sduser/.ssh#

FWIW, when I used the command line to ssh I get a similar thing for each one respectively:

Code:
ssh root
Linux thibworldpx3 5.15.39-1-pve #1 SMP PVE 5.15.39-1 (Wed, 22 Jun 2022 17:22:00 +0200) x86_64

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Wed Jul 20 14:35:50 2022 from 192.168.2.2
root@thibworldpx3:~#

ssh sduser
sduser@192.168.2.254's password:
Permission denied, please try again.
sduser@192.168.2.254's password:
Permission denied, please try again.
sduser@192.168.2.254's password:
sduser@192.168.2.254: Permission denied (publickey,password).

What am I missing?
 
Hi,
did you check the permissions on your authorized keys file it should be 644 aka user: rw, group: r, others: r) like this and belong to the user

Code:
$ ls -l .ssh/authorized_keys
-rw-r--r-- 1 user Unix 928 Jun 23 09:08 .ssh/authorized_keys
 
Hi,
did you check the permissions on your authorized keys file it should be 644 aka user: rw, group: r, others: r) like this and belong to the user

Code:
$ ls -l .ssh/authorized_keys
-rw-r--r-- 1 user Unix 928 Jun 23 09:08 .ssh/authorized_keys
That's it. It rw- rw---
Thank you!