sshd_config を変更した後、LAN 上でも SSH ログインが非常に遅くなる

sshd_config を変更した後、LAN 上でも SSH ログインが非常に遅くなる

ホームサーバーをインターネットから ssh できるようにしようとしています。

最初は(構成ファイルに触れる前に)、apt-get install openssh-serverローカル LAN 上で非常に速く(基本的に瞬時に)接続できました。実行するssh username@localIPと、すぐにパスワードの入力が求められ、ログインできました。

ファイルを次のように編集しましたsshd_config(デフォルトから):

# Package generated configuration file
# See the sshd_config(5) manpage for details

# What ports, IPs and protocols we listen for
Port 22
# Use these options to restrict which interfaces/protocols sshd will bind to
#ListenAddress ::
#ListenAddress 0.0.0.0
Protocol 2
# HostKeys for protocol version 2
HostKey /etc/ssh/ssh_host_rsa_key
HostKey /etc/ssh/ssh_host_dsa_key
HostKey /etc/ssh/ssh_host_ecdsa_key
HostKey /etc/ssh/ssh_host_ed25519_key
#Privilege Separation is turned on for security
UsePrivilegeSeparation yes

# Lifetime and size of ephemeral version 1 server key
KeyRegenerationInterval 3600
ServerKeyBits 1024

# Logging
SyslogFacility AUTH
LogLevel VERBOSE

# Authentication:
LoginGraceTime 120
PermitRootLogin no
StrictModes yes

RSAAuthentication yes
PubkeyAuthentication yes
#AuthorizedKeysFile %h/.ssh/authorized_keys

# Don't read the user's ~/.rhosts and ~/.shosts files
IgnoreRhosts yes
# For this to work you will also need host keys in /etc/ssh_known_hosts
RhostsRSAAuthentication no
# similar for protocol version 2
HostbasedAuthentication no
# Uncomment if you don't trust ~/.ssh/known_hosts for RhostsRSAAuthentication
#IgnoreUserKnownHosts yes

# To enable empty passwords, change to yes (NOT RECOMMENDED)
PermitEmptyPasswords no

# Change to yes to enable challenge-response passwords (beware issues with
# some PAM modules and threads)
ChallengeResponseAuthentication no

# Change to no to disable tunnelled clear text passwords
PasswordAuthentication no

# Kerberos options
#KerberosAuthentication no
#KerberosGetAFSToken no
#KerberosOrLocalPasswd yes
#KerberosTicketCleanup yes

# GSSAPI options
#GSSAPIAuthentication no
#GSSAPICleanupCredentials yes

X11Forwarding no
X11DisplayOffset 10
PrintMotd no
PrintLastLog yes
TCPKeepAlive yes
#UseLogin no

#MaxStartups 10:30:60
Banner /etc/issue.net

# Allow client to pass locale environment variables
AcceptEnv LANG LC_*

Subsystem sftp /usr/lib/openssh/sftp-server

# Set this to 'yes' to enable PAM authentication, account processing,
# and session processing. If this is enabled, PAM authentication will
# be allowed through the ChallengeResponseAuthentication and
# PasswordAuthentication.  Depending on your PAM configuration,
# PAM authentication via ChallengeResponseAuthentication may bypass
# the setting of "PermitRootLogin without-password".
# If you just want the PAM account and session checks to run without
# PAM authentication, then enable this but set PasswordAuthentication
# and ChallengeResponseAuthentication to 'no'.
UsePAM yes

これらは、上記のファイルで変更した行の初期状態です。

LogLevel INFO
PermitRootLogin without-password
#PasswordAuthentication yes
X11Forwarding yes
#Banner /etc/issue.net

これらを保存して終了し、sudo service ssh restartログインしようとしましたusername@localIPが、何らかの理由でログインに非常に時間がかかります。ログインすると、接続は非常に高速に見えます (LAN 上にあるため、当然のことです)。奇妙なのは、ドメイン名を経由しない場合でも、ログインに非常に時間がかかることです。

次に、ポート 22 をサーバーの静的 IP アドレスに転送してログインしようとしましたが[email protected]、ログインはさらに遅くなりました。サーバーに接続するのには約 2 分かかりました。接続すると、ターミナルを閉じて再接続することで手動でセッションを終了するまで、ランダムにフリーズして機能しなくなります。入力した後、まったく接続されずにハングアップすることがあります。ssh [email protected]

しかし、そうすると、ping example.comすべてのパケットが平均 ping 時間 10 ミリ秒で非常に速く戻ってくるように見えます。

設定がおかしくなっているのでしょうか? すべてを以前の状態に戻して SSH サーバーを再起動しようとしましたが、それでもログインに非常に時間がかかりますusername@localIP@

今のところ、サーバー上には 1 人のユーザー (当然ながら root 以外) しかおらず、クライアント マシンから rsa キー id_rsa.pub をファイルに手動でコピーしました~/.ssh/authorized_keys。フォルダーとファイルの両方を手動で作成する必要がありました.sshが、うまく機能しているようで、パスワードの入力を求められませんでした。

答え1

関連情報