منبع اصلی نوشتار زیر در این لینک قرار دارد

رفع مشکل کندی اتصال در ارتباط از طریق ssh

مشکل از اونجایی شروع شد که هر زمان میخواستم به سرور محل کار متصل بشم، از زمانی که دستور ssh رو میزدم تا لحظه‌ای که اتصال برقرار می‌شد زمان نسبتا زیادی سپری می‌شد که با توجه به اینکه اتصال بر روی شبکه محلی انجام می‌شد این تاخیر قابل قبول نبود.

برای بررسی مشکل، دستور ssh رو با سوییچ v- اجرا کردم تا ببینم مشکل مربوط به کجا میشه:

$ ssh -v [email protected]
OpenSSH_6.6.1, OpenSSL 1.0.1f 6 Jan 2014
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to 192.168.1.100 [192.168.1.100] port 22.
debug1: Connection established.
debug1: identity file /home/ali/.ssh/id_rsa type 1
debug1: identity file /home/ali/.ssh/id_rsa-cert type -1
debug1: identity file /home/ali/.ssh/id_dsa type -1
debug1: identity file /home/ali/.ssh/id_dsa-cert type -1
debug1: identity file /home/ali/.ssh/id_ecdsa type -1
debug1: identity file /home/ali/.ssh/id_ecdsa-cert type -1
debug1: identity file /home/ali/.ssh/id_ed25519 type -1
debug1: identity file /home/ali/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.6.1p1 Ubuntu-2ubuntu2
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.9p1 Debian-5ubuntu1.4
debug1: match: OpenSSH_5.9p1 Debian-5ubuntu1.4 pat OpenSSH_5* compat 0x0c000000
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: sending SSH2_MSG_KEX_ECDH_INIT
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ECDSA c4:8e:2b:b2:95:53:0c:98:d9:29:7c:ac:c4:0a:65:37
debug1: Host '192.168.1.100' is known and matches the ECDSA host key.
debug1: Found key in /home/ali/.ssh/known_hosts:3
debug1: ssh_ecdsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received # دقیقا در این قسمت برای چند ثانیه عملیات متوقف می‌شد
...

بعد از یک جستجوی ساده در اینترنت به این نتیجه رسیدم که اگر عبارت UseDNS no رو به فایل etc/ssh/sshd_config/ اضافه کرده و یک مرتبه سرویس ssh رو restart کنم مشکل برطرف می‌شه.

# echo 'UseDNS no' >> /etc/ssh/sshd_config
# service ssh restart

بعد از انجام مراحل بالا سرعت اتصال به سرور افزایش چشمگیری داشت :)



برچسب ها : ,