よくある質問
よくある質問: Tsukaeru Cloud
It takes time to connect via SSH over local network
投稿者: Wiktor Klonowski on 29 August 2016 06:49 PM

When connecting via SSH, server perform a reverse DNS lookup of client's IP address. However, when connecting inside local network and server or client do not have global IP address, it is impossible to perform DNS lookup, and server must wait for connection time out. Thus, connecting via SSH takes so much time.

There are two solutions to this problem.
(both need changing setting on a server)

  1. Adding information about local IP address to the hosts file

    Add the following to the /etc/hosts file:
    [client IP address] [client host name]

    E.g. When client IP address is 10.0.0.1 and host name private.example.com
    10.0.0.1 private.example.com

  2. Disable reverse DNS lookup in SSH settings

    Change the following in /etc/ssh/sshd_config file:

           #UseDNS yes
    to
           UseDNS no

    After saving changes reload SSH settings using the following command

    /etc/init.d/sshd reload