SSH接続タイムアウト

SSH接続タイムアウト

私のネットワークには2台のノートパソコンと2台のRaspberry Piがあります。問題は、2 台のコンピュータの 1 つから 1 つの RPi に SSH を送信できず、その RPi から別のコンピュータに SSH を送信できないことです。どちらのPiも、Raspbian Buster Liteを新しくインストールした状態で提供されます。 Piは正常にpingできますが、SSH接続がタイムアウトします。私のsshfsも期待どおりに動作しません。 ssh、openssh-client、openssh-serverをクリアして再インストールしてみましたが、成功しませんでした。デバッグ出力はあまり役に立たないか説明的ではありません。

$ ssh [email protected] -vvv
OpenSSH_7.6p1 Ubuntu-4ubuntu0.3, OpenSSL 1.0.2n  7 Dec 2017
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug2: resolving "192.168.0.15" port 22
debug2: ssh_connect_direct: needpriv 0
debug1: Connecting to 192.168.0.15 [192.168.0.15] port 22.
debug1: connect to address 192.168.0.15 port 22: Connection timed out
ssh: connect to host 192.168.0.15 port 22: Connection timed out

私のコンピュータはすべて192.168.0に*あります。

この問題を解決するにはどうすればよいですか?

@編集する:

以前は、あるノートブックではRPiにSSHで接続できましたが、別のノートブックではそうではありませんでした。今はどれでもそうすることはできません。

nmapポートスキャン出力:

$ nmap -p 22 192.168.0.15

Starting Nmap 7.60 ( https://nmap.org ) at 2019-12-17 17:05 CET
Nmap scan report for 192.168.0.15
Host is up (0.010s latency).

PORT   STATE    SERVICE
22/tcp filtered ssh

Nmap done: 1 IP address (1 host up) scanned in 0.43 seconds

RPi ではファイアウォールは実行されません。

$ sudo netstat --tcp --programs --listening --numeric
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      1335/sshd           
tcp6       0      0 :::22                   :::*                    LISTEN      1335/sshd  

必要に応じて:

$ sudo ip addr show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether b8:27:eb:ab:f8:fb brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.15/24 brd 192.168.0.255 scope global eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::ba27:ebff:feab:f8fb/64 scope link 
       valid_lft forever preferred_lft forever
3: wlan0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
    link/ether b8:27:eb:fe:ad:ae brd ff:ff:ff:ff:ff:ff
$ sudo ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.0.15  netmask 255.255.255.0  broadcast 192.168.0.255
        inet6 fe80::ba27:ebff:feab:f8fb  prefixlen 64  scopeid 0x20<link>
        ether b8:27:eb:ab:f8:fb  txqueuelen 1000  (Ethernet)
        RX packets 121039  bytes 19525595 (18.6 MiB)
        RX errors 0  dropped 11  overruns 0  frame 0
        TX packets 26795  bytes 5950306 (5.6 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 2  bytes 78 (78.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 2  bytes 78 (78.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

SSH構成ファイル:

壊れたパイ:

$ cat /etc/ssh/ssh_config

# This is the ssh client system-wide configuration file.  See
# ssh_config(5) for more information.  This file provides defaults for
# users, and the values can be changed in per-user configuration files
# or on the command line.

# Configuration data is parsed as follows:
#  1. command line options
#  2. user-specific file
#  3. system-wide file
# Any configuration value is only changed the first time it is set.
# Thus, host-specific definitions should be at the beginning of the
# configuration file, and defaults at the end.

# Site-wide defaults for some commonly used options.  For a comprehensive
# list of available options, their meanings and defaults, please see the
# ssh_config(5) man page.

Host *
#   ForwardAgent no
#   ForwardX11 no
#   ForwardX11Trusted yes
#   PasswordAuthentication yes
#   HostbasedAuthentication no
#   GSSAPIAuthentication no
#   GSSAPIDelegateCredentials no
#   GSSAPIKeyExchange no
#   GSSAPITrustDNS no
#   BatchMode no
#   CheckHostIP yes
#   AddressFamily any
#   ConnectTimeout 0
#   StrictHostKeyChecking ask
#   IdentityFile ~/.ssh/id_rsa
#   IdentityFile ~/.ssh/id_dsa
#   IdentityFile ~/.ssh/id_ecdsa
#   IdentityFile ~/.ssh/id_ed25519
#   Port 22
#   Protocol 2
#   Ciphers aes128-ctr,aes192-ctr,aes256-ctr,aes128-cbc,3des-cbc
#   MACs hmac-md5,hmac-sha1,[email protected]
#   EscapeChar ~
#   Tunnel no
#   TunnelDevice any:any
#   PermitLocalCommand no
#   VisualHostKey no
#   ProxyCommand ssh -q -W %h:%p gateway.example.com
#   RekeyLimit 1G 1h
    SendEnv LANG LC_*
    HashKnownHosts yes
    GSSAPIAuthentication yes

$ cat /etc/ssh/sshd_config
#   $OpenBSD: sshd_config,v 1.103 2018/04/09 20:41:22 tj Exp $

# This is the sshd server system-wide configuration file.  See
# sshd_config(5) for more information.

# This sshd was compiled with PATH=/usr/bin:/bin:/usr/sbin:/sbin

# The strategy used for options in the default sshd_config shipped with
# OpenSSH is to specify options with their default value where
# possible, but leave them commented.  Uncommented options override the
# default value.

#Port 22
#AddressFamily any
#ListenAddress 0.0.0.0
#ListenAddress ::

#HostKey /etc/ssh/ssh_host_rsa_key
#HostKey /etc/ssh/ssh_host_ecdsa_key
#HostKey /etc/ssh/ssh_host_ed25519_key

# Ciphers and keying
#RekeyLimit default none

# Logging
#SyslogFacility AUTH
#LogLevel INFO

# Authentication:

#LoginGraceTime 2m
#PermitRootLogin prohibit-password
#StrictModes yes
#MaxAuthTries 6
#MaxSessions 10

#PubkeyAuthentication yes

# Expect .ssh/authorized_keys2 to be disregarded by default in future.
#AuthorizedKeysFile .ssh/authorized_keys .ssh/authorized_keys2

#AuthorizedPrincipalsFile none

#AuthorizedKeysCommand none
#AuthorizedKeysCommandUser nobody

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

# To disable tunneled clear text passwords, change to no here!
#PasswordAuthentication yes
#PermitEmptyPasswords no

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

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

# GSSAPI options
#GSSAPIAuthentication no
#GSSAPICleanupCredentials yes
#GSSAPIStrictAcceptorCheck yes
#GSSAPIKeyExchange no

# 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

#AllowAgentForwarding yes
#AllowTcpForwarding yes
#GatewayPorts no
X11Forwarding yes
#X11DisplayOffset 10
#X11UseLocalhost yes
#PermitTTY yes
PrintMotd no
#PrintLastLog yes
#TCPKeepAlive yes
#PermitUserEnvironment no
#Compression delayed
#ClientAliveInterval 0
#ClientAliveCountMax 3
#UseDNS no
#PidFile /var/run/sshd.pid
#MaxStartups 10:30:100
#PermitTunnel no
#ChrootDirectory none
#VersionAddendum none

# no default banner path
#Banner none

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

# override default of no subsystems
Subsystem   sftp    /usr/lib/openssh/sftp-server

# Example of overriding settings on a per-user basis
#Match User anoncvs
#   X11Forwarding no
#   AllowTcpForwarding no
#   PermitTTY no
#   ForceCommand cvs server

働くパイ:

$ cat /etc/ssh/ssh_config 

# This is the ssh client system-wide configuration file.  See
# ssh_config(5) for more information.  This file provides defaults for
# users, and the values can be changed in per-user configuration files
# or on the command line.

# Configuration data is parsed as follows:
#  1. command line options
#  2. user-specific file
#  3. system-wide file
# Any configuration value is only changed the first time it is set.
# Thus, host-specific definitions should be at the beginning of the
# configuration file, and defaults at the end.

# Site-wide defaults for some commonly used options.  For a comprehensive
# list of available options, their meanings and defaults, please see the
# ssh_config(5) man page.

Host *
#   ForwardAgent no
#   ForwardX11 no
#   ForwardX11Trusted yes
#   PasswordAuthentication yes
#   HostbasedAuthentication no
#   GSSAPIAuthentication no
#   GSSAPIDelegateCredentials no
#   GSSAPIKeyExchange no
#   GSSAPITrustDNS no
#   BatchMode no
#   CheckHostIP yes
#   AddressFamily any
#   ConnectTimeout 0
#   StrictHostKeyChecking ask
#   IdentityFile ~/.ssh/id_rsa
#   IdentityFile ~/.ssh/id_dsa
#   IdentityFile ~/.ssh/id_ecdsa
#   IdentityFile ~/.ssh/id_ed25519
#   Port 22
#   Protocol 2
#   Ciphers aes128-ctr,aes192-ctr,aes256-ctr,aes128-cbc,3des-cbc
#   MACs hmac-md5,hmac-sha1,[email protected]
#   EscapeChar ~
#   Tunnel no
#   TunnelDevice any:any
#   PermitLocalCommand no
#   VisualHostKey no
#   ProxyCommand ssh -q -W %h:%p gateway.example.com
#   RekeyLimit 1G 1h
    SendEnv LANG LC_*
    HashKnownHosts yes
    GSSAPIAuthentication yes
$ cat /etc/ssh/sshd_config 
#   $OpenBSD: sshd_config,v 1.103 2018/04/09 20:41:22 tj Exp $

# This is the sshd server system-wide configuration file.  See
# sshd_config(5) for more information.

# This sshd was compiled with PATH=/usr/bin:/bin:/usr/sbin:/sbin

# The strategy used for options in the default sshd_config shipped with
# OpenSSH is to specify options with their default value where
# possible, but leave them commented.  Uncommented options override the
# default value.

#Port 22
#AddressFamily any
#ListenAddress 0.0.0.0
#ListenAddress ::

#HostKey /etc/ssh/ssh_host_rsa_key
#HostKey /etc/ssh/ssh_host_ecdsa_key
#HostKey /etc/ssh/ssh_host_ed25519_key

# Ciphers and keying
#RekeyLimit default none

# Logging
#SyslogFacility AUTH
#LogLevel INFO

# Authentication:

#LoginGraceTime 2m
#PermitRootLogin prohibit-password
#StrictModes yes
#MaxAuthTries 6
#MaxSessions 10

#PubkeyAuthentication yes

# Expect .ssh/authorized_keys2 to be disregarded by default in future.
#AuthorizedKeysFile .ssh/authorized_keys .ssh/authorized_keys2

#AuthorizedPrincipalsFile none

#AuthorizedKeysCommand none
#AuthorizedKeysCommandUser nobody

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

# To disable tunneled clear text passwords, change to no here!
#PasswordAuthentication yes
#PermitEmptyPasswords no

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

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

# GSSAPI options
#GSSAPIAuthentication no
#GSSAPICleanupCredentials yes
#GSSAPIStrictAcceptorCheck yes
#GSSAPIKeyExchange no

# 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

#AllowAgentForwarding yes
#AllowTcpForwarding yes
#GatewayPorts no
X11Forwarding yes
#X11DisplayOffset 10
#X11UseLocalhost yes
#PermitTTY yes
PrintMotd no
#PrintLastLog yes
#TCPKeepAlive yes
#PermitUserEnvironment no
#Compression delayed
#ClientAliveInterval 0
#ClientAliveCountMax 3
#UseDNS no
#PidFile /var/run/sshd.pid
#MaxStartups 10:30:100
#PermitTunnel no
#ChrootDirectory none
#VersionAddendum none

# no default banner path
#Banner none

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

# override default of no subsystems
Subsystem   sftp    /usr/lib/openssh/sftp-server

# Example of overriding settings on a per-user basis
#Match User anoncvs
#   X11Forwarding no
#   AllowTcpForwarding no
#   PermitTTY no
#   ForceCommand cvs server

ベストアンサー1

まだレビューは書けませんが、nmapドキュメント:

フィルタリングされたことは、ファイアウォール、フィルタ、またはその他のネットワーク障害がポートをブロックして、Nmapがポートが開いているか閉じているかを確認できないことを意味します。閉じたポートにはアプリケーションのリスニングはありませんが、いつでも開くことができます。ポートがNmapのプローブに応答すると、フィルタリングされていないと分類されますが、Nmapはポートが開いているか閉じているかを確認できません。 Nmapは、2つの状態のいずれがポートを記述しているかを判断できない場合、open | filteredとclose | filtered状態の組み合わせを報告します。

私の考えでは、ルータが何らかの方法でポートをブロックしていて、動作している他のraspiがバグかもしれません。確認してみてください。これ何かを変更した場合、または一般的な内容を変更した場合は、ルーター/スイッチを再起動してください。

また、モジュールを交換してハードウェア障害を排除するのに役立ちます。つまり、作業モジュールの壁面ソケット/電源装置を使用し(電流量が十分である必要があります)、作業モジュールのブレーカー付きSDカードを挿入します。動作しないモジュールまたは他の方法で(一度 - ネットワークアダプタに障害があります)。

パスワード認証やrsaファイルも使用しますか?

/etc/hosts ファイルには、2 つのパイ (動作するパイと ssh の問題があるパイ) に何が含まれていますか? (猫/背中/ホスト)

また、動作しないPiと動作するRaspberry Piとの潜在的な違いについては、/etc/ssh/ssh_config(クライアント構成)および/etc/ssh/sshd_config(sshサーバー構成)の内容を提供してください。 (cat/etc/ssh/ssh_config &&cat/etc/sshd_config)


編集:追加の試み

インターネットはうまく動作します(インターネットはポート80、8080、および443を介して実行されます)、「壊れた」パイで次のことを試すことができます。

  1. /etc/ssh/sshd_conf のコメントを外し# Port 22、次に変更します。Port 80 それでも機能しない場合は、ポートが利用可能である必要があるため、Port 443に変更します。 (安全な変更をPort 8080使用して変更して使用できます)sudo nano /etc/ssh/sshd_confctrl + x

  2. 各変更のsudo systemctl restart sshd.service間に各変更の間に別のデバイスから破損したパイに再接続しようとします。ssh -p 80 [email protected]

-pはポートを変更し、systemctlを使用してアダプタを再起動したため、ポート変数を示します(確認したい場合は、毎回piを再起動することもできます)。

  1. Port 22それでも機能しない場合は、ポートをもう一度変更してください。(注:SSHが有効なパブリックサーバーがある場合は、ポート2409などのランダム攻撃を容易にするために、ポートを非一般的なポートに変更する必要があります。)

  2. デーモンの状態を確認することもできます。破損したパイの出力にロードされていないエラーまたは「失敗」エラーがある場合は、そのsudo systemctl status sshd.service内容も公開してください。

  3. ハードウェアにアクセスするのは簡単ではないようですが、それほど問題にならない場合は、インターネットが機能し、愚かな場合でもハードウェアを交換することをお勧めします。私は最も過酷なハードウェアの問題を経験しました。電気的には一連の信号であり、変調器モジュールは予期しない動作をする可能性があります。そして、「うまくいきますがうまくいきませんでした」ので、私は何年もの間最も面白い問題を経験しました。ハードウェアの欠陥を実際の可能性にするからです。

  4. ポートが原因であれば、SSHはすでに別のポートを介して機能する必要があります。それ以外の場合、追加の手順は次のとおりです。 IDが機能しない前に更新(fe sudo apt update&&sudo apt update)したかインストールしましたか?覚えているものはありますか?動作しない前に最小の変更は何ですか?最近更新しましたか(sudo apt update && sudo apt update -y)?そうでない場合は、今すぐ更新してパイを再起動してください。時には役に立ちます。

おすすめ記事