troubleshooting really slow login on a (linux) machine

Solution 1:

I have had similar issues - in our case we found that there was some old config left over where a name of a system or a DNS server was configured but was not accessible.

Suggestions from me: ensure DNS resolution is working fine on the machine you are connecting to. If you have assigned a hostname to the machine make sure that you edit the /etc/hosts file to at least have a matching entry for the 127.0.0.1 address like this:

127.0.0.1    server-name localhost.localdomain localhost

If you are using static IPs also add:

<static ip>  server-name

Solution 2:

You probably have a problem with either file:

/var/log/wtmp
/var/run/utmp

The last command may give you strange result. You can use the setutent command to repair it. Or just the simple way:
1. log as root and rename the 2 files.
2. don't log out, for security.
3. log in with whatever user, then log out. The 2 files should be recreated.
4. as root: last should give you a sensible output.
5. if you are sure everything is okay, delete the 2 files