sshで他のマシンにログインするときに遅い時の対処法

最近やたらとsshで接続するまでに時間がかかるようになったのでちょっと調べてみました。以下まとめ。

sshに -v オプションつけてデバックログを出してみる。こんな感じの出力がでるはず。

debug1: ssh_rsa_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  1)
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
debug1: Next authentication method: gssapi-keyex
debug1: No valid Key exchange context
debug1: Next authentication method: gssapi-with-mic  2)
debug1: Unspecified GSS failure.  Minor code may provide more information
Credentials cache file '/tmp/krb5cc_1000' not found

  • 1)で遅い場合
  • ログイン先(リモート側)でホスト名を解決しようとして時間がかかっているっぽい。ログイン先の /etc/ssh/sshd_config に以下を追記してssh再起動で解決。
    UseDNS no
    

  • 2)で遅い場合
  • GSSという認証方式(?)で認証しに行こうとして時間がかかっているっぽい。ローカル側の ~/.ssh/config (もしくは /etc/ssh/ssh_config でもいいと思う)に以下を追記して解決。
    GSSAPIAuthentication no
    

このブログの人気の投稿

zsh 設定 - プロンプト -

テンションを上げたいときにおすすめの曲(StarrySky YEAH! Remix)

OpenLDAP のログ周りの設定をする