SSH接続が遅すぎる

SSH接続が遅すぎる

メモリが500 MBのローカルCentos 6.3仮想マシンに接続できません。

接続の出力は次のとおりですssh -vvv localhost

OpenSSH_6.3, OpenSSL 1.0.1e 11 Feb 2013
debug1: Reading configuration data /usr/local/etc/ssh_config
debug2: ssh_connect: needpriv 0
debug1: Connecting to localhost [127.0.0.1] port 22.
^^^^^^^^^^ Loading this statement takes more than a minute

debug1: Connection established.
...

debug1: Next authentication method: password 
root@localhost's password:
^^^^^^^^^^ This step takes a minute too

debug3: packet_send2: adding 64 (len 50 padlen 14 extra_pad 64)
debug2: we sent a password packet, wait for reply
debug1: Authentication succeeded (password).
Authenticated to localhost ([127.0.0.1]:22).
debug1: channel 0: new [client-session]
debug3: ssh_session2_open: channel_new: 0
debug2: channel 0: send open
debug1: Requesting [email protected]
debug1: Entering interactive session.
debug2: callback start
debug2: fd 3 setting TCP_NODELAY
debug3: packet_set_tos: set IP_TOS 0x10
debug2: client_session2_setup: id 0
debug2: channel 0: request pty-req confirm 1
debug2: channel 0: request shell confirm 1
debug2: callback done
debug2: channel 0: open confirm rwindow 0 rmax 32768
debug2: channel_input_status_confirm: type 99 id 0
debug2: PTY allocation request accepted on channel 0
debug2: channel 0: rcvd adjust 2097152
debug2: channel_input_status_confirm: type 99 id 0
debug2: shell request accepted on channel 0
Last login: Wed Oct  9 13:27:02 2013 from 10.0.0.2

この遅延を取り除く方法を提案してください。

ベストアンサー1

私の考えでは、問題はDNS要求のタイムアウトです。ホスト名の代わりにIPアドレスで接続を試み、UseDNS接続したいサーバーのオプションをオフにします。さらに:

  1. ssh localhostVMホストから接続すると仮定すると、ゲストVMではなくホストに接続したいと思います。もちろん、興味深いネットワーク設定がなければ。

  2. 最初の遅延の場合は、これを実行してクライアント側の保留中のstraceシステムコールを確認できます。ssh

  3. 2番目の遅延の場合は、top仮想マシンで実行して仮想マシンに接続したときに何が起こるかを確認してください。その間、代替ポートでデバッグモードでSSHデーモンを実行してインスタンスに接続することをお勧めします。待機中の場所を確認できます。ルートとして実行するだけです。

    sshd -ddd -p 2222 -o UsePrivilegeSeparation=no
    

    これにより、ポート2222でSSHデーモンが起動し、多くの情報(-ddd)が記録され、ログイン中に権限分離を使用しなくなります(権限分離を無効にすると1つのプロセスのみが使用されるため、straceで何が起こっているかをより簡単に確認できます)。-o UseDNS=no上記のオプションを追加して無効にすることもできます。

おすすめ記事