Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delay when attempting to SSH to a system

Tags:

bash

ssh

openssh

I am facing a delay of about 5-6 seconds when I try to ssh from my system to a friend's system. Here is the verbose output of the command :

zeus@athena:~$ ssh -v [email protected]
OpenSSH_5.3p1 Debian-3ubuntu7, OpenSSL 0.9.8k 25 Mar 2009
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug1: Connecting to 192.168.40.211 [192.168.40.211] port 22.
debug1: Connection established.
debug1: identity file /home/zeus/.ssh/identity type -1
debug1: identity file /home/zeus/.ssh/id_rsa type 1
debug1: Checking blacklist file /usr/share/ssh/blacklist.RSA-2048
debug1: Checking blacklist file /etc/ssh/blacklist.RSA-2048
debug1: identity file /home/zeus/.ssh/id_dsa type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_6.0p1 Debian-3ubuntu1
debug1: match: OpenSSH_6.0p1 Debian-3ubuntu1 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.3p1 Debian-3ubuntu7
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5 none
debug1: kex: client->server aes128-ctr hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Host '192.168.40.211' is known and matches the RSA host key.
debug1: Found key in /home/zeus/.ssh/known_hosts:71
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received

<---- delay 4-5 seconds------>


debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: Trying private key: /home/zeus/.ssh/identity
debug1: Offering public key: /home/zeus/.ssh/id_rsa
debug1: Authentications that can continue: publickey,password
debug1: Trying private key: /home/zeus/.ssh/id_dsa
debug1: Next authentication method: password

Can someone help me figure out how i can get rid of this delay?

like image 709
Ashwin Lakshmanan Avatar asked Nov 09 '13 13:11

Ashwin Lakshmanan


2 Answers

As suggested in the comments, this could be a DNS issue. There's an article covering some steps to try and solve this here: http://www.thegeekstuff.com/2010/07/openssh-slow-at-ssh2_msg_service_accept-received/

The advice given boils down to editing /etc/sshd_config adding / changing UseDNS no and then restarting sshd. Obviously that can be tricky without access to the server!

It should also be pointed out, that setting UseDNS to no might not be the best solution in the long term. Probably better to fix the DNS issue, if there is one, on the machine in question.

like image 93
chmac Avatar answered Sep 24 '22 15:09

chmac


My question seems to have an answer here:

https://superuser.com/a/654153/152271

It seems that remote host tries to do a nslookup to my hostname (the connecting one). After editing /etc/hosts in the remote host adding my IP/hostname, it fixed the delay.

like image 28
JorgeeFG Avatar answered Sep 21 '22 15:09

JorgeeFG