3 added 153 characters in body
source | link

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). Because theyMy users have no password (and this is wanted), they can't sudo anything. ButNevertheless, 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.

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). Because they have no password (and this is wanted), they can't sudo anything. But 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?

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.

2 edited title
| link

Use current user environnmentenvironment variable in sudoersudoers file

1
source | link

Use current user environnment variable in sudoer file

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). Because they have no password (and this is wanted), they can't sudo anything. But 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?