0

Is there a way to give the root user a temporary password? That is, after a certain time, or after it is manually deactivated, the password will be deleted.

I want to give my colleague permission to access a server as root for a certain amount of time (like a day) so he can use ssh root@xxx.xx.xx.xx. After that, the password I give him will expire, and attempts to use it to log in will be rejected.

Is there a way to do this?

  • 1
    IMO you should add the user to the sudo group and remove from the sudo group when done. Alternately you can enable and disable the account but setting a root password comes with some security risk, especially over ssh. When I allow root to ssh in I always use ssh keys and disable password authentication. – Panther Oct 27 '14 at 13:39
1

Try passwd -x 1. From man passwd:

   -x, --maxdays MAX_DAYS
       Set the maximum number of days a password remains valid. After
       MAX_DAYS, the password is required to be changed.

This does not, of course, prevent your colleage from setting a password of their own choice, or using SSH keys to login.

You could also try usermod -e. From man usermod:

   -e, --expiredate EXPIRE_DATE
       The date on which the user account will be disabled. The date is
       specified in the format YYYY-MM-DD.

All of this is moot since you are giving the root password. The colleague can always undo whatever measure you put up.

It would be best if you give the user exactly as much privilege as they require, using sudo.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.