I want some of my users to be able to change their password with sudo command because at the time they log in, they are passwordless (ssh keys connection). My users have no password (and this is wanted), they can't sudo
anything. Nevertheless, I want them to be able to do only one sudo command: sudo passwd $USER
, so they can choose a password.
Here is the interesting parts of my sudoers file:
Defaults!/usr/bin/passwd env_keep=SUDO_USER
%restrictedgroup ALL = NOPASSWD: /usr/bin/passwd $SUDO_USER
It doesn't work. How can I access the current SUDO_USER environnement variable in sudoers file?
EDIT: I have another important contraint in my context: I can't set a dummy password to every single users. It means they really can't change their password without sudo
.
passwd
? You don't needsudo
to change your own user's password.sudo
. You can't change a password if you don't have one previously set, unless you are root (or sudo). That's why.pass
and then having them change it be an option?su
. Of course, another solution is to make a different silly password to everyone, but this is my contraint: I can't do that easily in my context.