9

I am horribly impatient and can't stand the (for me subjectively long) delay of around 2 seconds after entering an incorrect password in the login screen or also as sudo password, before I can retry typing it correctly.

Is there a way to modify the delay and reduce it to around half a second or turn it completely off, both for sudo and the login screen?

The optimal solution would include a longer delay after maybe 3 or 5 incorrect passwords, to still prevent brute-forcing.

PS: I am currently using vanilla Ubuntu 16.04 with Unity Desktop and lightdm.

13

In Ubuntu, to remove the delay for incorrect passwords in the terminal, edit the file common-auth found in the folder /etc/pam.d.

sudo nano /etc/pam.d/common-auth

Then add the string nodelay to the end of the line

auth    [success=1 default=ignore]      pam_unix.so nullok_secure

so that it says

auth    [success=1 default=ignore]      pam_unix.so nullok_secure nodelay

Then save the file with nano by pressing Ctrl+X, Y, Enter.

If you want to instead change the delay, first do the step above and remove the delay completely. Then add the following line to the same file before the line you altered above:

auth       optional     pam_faildelay.so  delay=500000

This will be the first uncommented line of the file. If you add this line after the first line you edited, then it won't work.

Now you can edit the delay value to whatever you want. I put a half second like you wanted.

| improve this answer | |
  • This works, but I would rather like a short (or even incremental, but I doubt this is possible without oversized effort) delay than zero. Thanks for your answer anyway, I'll accept it if nothing better comes up within the next days. – Byte Commander Jan 31 '17 at 22:21
  • Okay, I finally figured it out. I will edit my answer to include changing the delay as well. – LateAsAlways2016 Feb 1 '17 at 7:19
  • Wonderful, that does exactly what I wanted. Thank you a lot. :) – Byte Commander Feb 1 '17 at 10:29
  • Note also that this requires a reboot. – Ray Mar 5 '18 at 15:30
  • 1
    This works fine without reboot on Ubuntu 20.04, but only for the sudo command. If I log out of the graphical screen and login again, ther is still a 3s delay on a failed attempt – rubo77 Jun 1 at 7:58
4

If you want to lower the delay rather than disabling it altogether, edit /etc/pam.d/login:

sudoedit /etc/pam.d/login

Find the line that looks like:

auth       optional   pam_faildelay.so  delay=3000000

Change the number after delay= to a smaller value, as desired.
Note that the number is in microseconds, so 1000000 is 1 second.


Sources:

| improve this answer | |
  • I edited the value to delay=500000 (should equal 0.5s) and rebooted, but the change had no effect on the lightdm login screen. Maybe it ignores that setting and has its own configuration? It is also not used by sudo either. – Byte Commander Jan 31 '17 at 21:56
  • It seems this is an outdated method. It doesn't work for me either. And, though it's not Ubuntu specifically, here are some people on stackexchange commenting about how they managed to get it to work by putting the nodelay into pam_unix.so and then afterward going to pam_faildelay.so and changing the delay. However, I tried doing it, and it didn't work for me either. – LateAsAlways2016 Feb 1 '17 at 6:23
  • 2
    works fine on Ubuntu 20.04 but only for the commandline- login, not for the graphical Ubuntu-Login – rubo77 Jun 1 at 7:59
2

To get your system to ignore the default password security delay add nodelay to the /etc/pam.d/common-auth file:

Change this line:

auth    [success=1 default=ignore]      pam_unix.so nullok_secure

To:

auth    [success=1 default=ignore]      pam_unix.so nullok_secure nodelay

Then reboot the system for it to take effect.

Note:

Formally done here /etc/login.defs but now handled by PAM in the /etc/pam.d by various configuration files.

| improve this answer | |

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.