Interview Prep/Linux/SSH, sudo and authentication

SSH login takes 20–30 seconds before the password or key prompt appears.

IntermediateTroubleshootingSSH, sudo and authentication
Answer

Likely causes → sshd does a reverse DNS lookup of the client (UseDNS yes) and DNS times out, or GSSAPI authentication attempts time out.

Diagnose →

ssh -vvv user@server 2>&1 | grep -E 'debug1:.*(GSSAPI|Authentications)' 
grep -Ei 'UseDNS|GSSAPIAuthentication' /etc/ssh/sshd_config /etc/ssh/sshd_config.d/*

Fix → Set UseDNS no and GSSAPIAuthentication no (if not using Kerberos) on the server; on the client GSSAPIAuthentication no. Fix DNS if it's broken generally.

Prevent → Keep sshd baseline config consistent.

All Linux questions Roadmap: Linux

More on SSH, sudo and authentication