7

I have this kind of behavior and I don't know how to fix it or even how to search a fix for it since I don't know how would I even call it.

Here's what's happening:

The first time I boot, when I type out the username and press Retrun the password prompt appears about a half or a quarter seconds later. The problem is that after I type the username I usually press Return and immediately start typing the password; however since the Password: hasn't appeared yet, the tty starts printing the characters I type directly onto the screen.

For example, let's say my username and password are: Username and Password respectively. If I were to login in a tty1 it would look something like this. The "Pa" at the beginning is there because I had started typing "Password" before Password: actually appeared.

Debian GNU/Linux stretch/sid hostname tty1

hostname login: Username
PaPassword:

A simple solution to this would of course be to type the username and wait a little before typing out the password, however I wish to get to the bottom of this and find the cause of this problem. I have a fear that some day the prompt could lag a lot longer than a quarter of a second (e.g. few seconds) and I would have accidentally typed my whole password onto screen before the Password: finally appeared.

Is there a way to know what's happening here?

  • 1
    Are you using a local user/password database or something remote, such as NIS, AD, or LDAP? – Mark Plotnick Jul 14 '15 at 19:11
  • 1
    Yes, it is a local user placed on a local machine. – orange orange Jul 14 '15 at 19:17
  • Does getent passwd Username exhibit any lag ? – steve Jul 14 '15 at 21:27
  • 1
    The initial delay is probably because code needs to be loaded into memory; after the first time the code is in the cache and hence can then be loaded quickly. Alternatively, the system is still busy with daemons initializing etc. so the login program simply doesn't get the CPU cycles quickly enough. – wurtel Jul 15 '15 at 8:33
  • I have the same problem. Do we have to just accept this behaviour or someone found a way to fix it? – Al.G. May 19 '16 at 7:31
2

The default behaviour of the TTY is to echo (immediately display) whatever the user types to the screen. This provides instant feedback of keys pressed. This is the mode the TTY device is in when the login: prompt is shown.

Before asking for the password, the login program makes a system call to change the mode of the TTY to not echo typed characters (so that your password is not shown as you type it). However, if you start typing characters before the login program actually executes that system call, then those characters will indeed be shown.

After asking for the password, the login program sets the TTY echo mode back to the default (echo what the user types).

  • This answer explains why the password is initially shown but does not explain why the delay is so large. – Bob May 14 '17 at 12:22
2

As @wurtel said in his comment, I believe that the login process is being timesliced by other boot-time processes, combined with hard drive I/O. The ironic answer would be to log in (natch!) and watch top and/or iostat and/or vmstat to see what the system is busy doing while you try to log in (again).

I would say "always wait for the password prompt" (because you don't want to risk giving your password to the wrong program or person!) but I'll be the first to admit that I've done it many times. I've seen system logs where a user clearly got mixed up between the username prompt and the password prompt, and we get system logs like "login failed for P@ssW0rD". It can be a remote ssh session, FTP session, anything that asks for credentials while the system is busy doing other things -- the main point I would make is that you should make sure you have the right system's attention before you provide your input.

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.