Macos – SSH remote login without password is very slow

debianmacosopenssh

SSH Client – Mac OS X Lion
SSH Server – Debian

/etc/hosts on Mac -> [IP of Debian] mydebian
Public key of Mac has already been put to authorized_key in root@mydebian:/root/.ssh
'UseDNS no' has been put to root@mydebian:/etc/ssh/sshd_config and then SSH server restarted

ssh root@mydebian -> wait for a long time to login
ssh -v root@mydebian -> no delay at all

Any ideas?

Best Answer

Set the following value in /etc/ssh_config:

AddressFamily inet 

(You can set it in ~/.ssh/config as well.)

The reason is that ssh is trying to do IPv6 negotiation, which apparently fails after a timeout, which happened to me after migration to a new Lion (10.7.4) MacBook Pro.

Related Question