0

I'm not trying to delete my password or anything. I just want ubuntu to remember my password after I login as an admin user and use that when installing/removing software or running sudo commands. The non-admin users should be prompt for the admin password though. Is there a way to do that and if so why doesn't ubuntu do that as default?

0

2 Answers 2

2

There's no such thing as "an admin password" in Ubuntu. Any user can elevate his privileges by using sudo as long as that is available to him. And by default sudo requires you to re-authenticate for security reasons. This is a sane default for this reasons as it fits with the "secure by default" policy.

However, it does remember it for a short period of time. Here's a question on how: How does sudo remember you already entered root's password?

Several options to go from here:

  • Passwordless sudo

    From the manpage of sudoers(5):

    By default, sudo requires that a user authenticate him or herself before running a command. This behavior can be modified via the NOPASSWD tag.

    Just change the lines in /etc/sudoers to include this. E.g.:

    %admin  ALL=(ALL) ALL
    %sudo   ALL=(ALL:ALL) ALL
    

    becomes

    %admin  ALL=(ALL) NOPASSWD: ALL
    %sudo   ALL=(ALL:ALL) NOPASSWD: ALL
    
  • Extend timeout

    By default sudo will "remember" your password to elevate your privileges again for fifteen minutes. You can extend this to a much longer time, let's say a day. Do note that this is not unlocked on login, but only triggered the first time you are elevating your privileges.

    To extend this, edit the /etc/sudoers file and locate the line

    Defaults        env_reset
    

    and append ,timestamp_timeout=1440 to it so it becomes

    Defaults        env_reset,timestamp_timeout=1440
    

    Alternatively, use -1 (a negative value) to have a really indefinite timeout. Read more about this on the Ubuntu Community wiki: RootSudoTimeout.

Important note! Editing the /etc/sudoers file should be done with great care. Incorrect syntax will result in a system on which you are probably not be able to elevate your privileges again and you'll have to perform a rather complicated password recovery. To edit it safely, use the sudo visudo command in the terminal. It will not directly write to the file, but only when you exit and save it and the syntax is correct. This will prevent a lot of trouble.

3
  • I'd like to just point out that there is a reason for why the password prompt is there, and that by disabling it, you're effectively removing critical parts of the security layer - and that this shouldn't be done on any kind of production machine.
    – sakjur
    Apr 6, 2013 at 14:44
  • What I wanted was to be asked for password at only login screen and never after that point. You are saying it is not possible?
    – Serhat
    Apr 6, 2013 at 15:57
  • maybe possible, but certainly not adviseable
    – pfeiffep
    Apr 6, 2013 at 16:28
0

In your system settings - little gear icon in right top corner - you can open Users. Click on the user you want to modify for the passwordless login. In the settings dialogue you can change the setting automatic login.

2
  • 3
    I don't think this is a login setting to change as I think OP is asking for a way to have an indefinite sudo password remember time.
    – gertvdijk
    Apr 6, 2013 at 14:08
  • But it's this answer that other people may have looked for, when searching Google for ubuntu automatic login ;) It's this answer that I was looking for, at any rate. May 6, 2014 at 3:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .