i have a small (4 seconds) login delay on my 18.04 ubuntu servers, that drives me crazy:
$ time ssh root@gateway exit
real 0m4,066s
user 0m0,015s
sys 0m0,005s
I've already checked the "usual" culprits: DNS, Avahi, pam_systemd.so, they aren't the cause. I've also shorten out /etc/profile, /etc/bash.bashrc, /root/.bashrc by putting a "exit 0" in the beginning of these files. It causes a little faster connect of 0m3,915s. So, they aren't the cause, either.
The ssh -vvv
shows, the whole time is lost after:
...
debug1: channel 0: new [client-session]
debug3: ssh_session2_open: channel_new: 0
debug2: channel 0: send open
debug3: send packet: type 90
debug1: Requesting [email protected]
debug3: send packet: type 80
debug1: Entering interactive session.
debug1: pledge: network
So, it seems not a problem with ssh itself. I'am guessing, there are running additional scripts on login that are stealing my time, but which are they and where they get triggerd?
Thanks for the hint with
/etc/update-motd.d/
, i've quashed most of these buggers there one by one. Problem is solved.Hall of shame:
I just had the same problem, but the existing solutions didn't solve it. The timing was even worse:
To debug what was taking so long, I increased the ssh verbosity via the
-vvv
option as in...which made it obvious that the time was taken during the
pledge: network
stage, which allowed me to search for that specific problem.What helped in the end was to
UsePAM
tono
in /etc/ssh/sshd_config as suggested on ServerFault,sudo service sshd restart
.According to this post on ubuntuforums, disabling PAM should be fine when using keys:
I once had a similar problem. It turned out that it was a printer that had a fault and was blasting the network with job requests or something. Replaced the printer and most of the network problems evaporated.