Linux tip, Fedora tip / howto: ssh pauses a long time before giving the password prompt

 
Note that these tips are mostly outdated


back to notes and tips index

Try my online puzzle page with Calcudoku, Killer Sudoku and online Sudoku.

ssh pauses a long time before giving the password prompt

This was a problem I had when ssh'ing to a Macbook: it would take more than 20 seconds before I'd get the password prompt. Running sshd in debug mode on the Macbook showed the following ("userid" is my user id):
debug1: PAM: initializing for 'userid'

After the 20 second pause it would give:
debug1: PAM: setting PAM_RHOST to "192.168.1.4"
Failed none for userid from 192.168.1.4 port 37950 ssh2
Failed none for userid from 192.168.1.4 port 37950 ssh2

It turns out this is because PAM is trying to get a host name for the given IP (in this case, 192.168.1.4). This is the fixed IP for my PC, and somehow the DNS of my router doesn't do anything useful.

The fix is to add a line to the /etc/hosts file on the Macbook:
192.168.1.4 myhostname
(with "myhostname" the name of your host).

There may be other fixes, maybe to the router. The system.log file on the Macbook claims my router is a "defective DNS relay" ...

use UseDNS no in your sshd config

Someone alerted me to another option: add the line:

UseDNS no

to your /etc/ssh/sshd_config file, which prevents the ssh daemon from doing a reverse DNS lookup.


← back to notes and tips index
Please do not copy the text of this tip (© Patrick Min) to your web site.