これが発生する理由:[My Host IP]ポート22によって接続が終了しました。

これが発生する理由:[My Host IP]ポート22によって接続が終了しました。

これは、Busterを実行しているPi 4で行われました。

私はPiでWebホスト(HostGator)でSSHを試しています。

RSAキーペアを使用してMacからHostGatorにSSHを接続できるため、ホストでSSHが実行されていることがわかります。パスワードは必要ありません。

MrMuscle:~ mnewman$ ssh mgnewman@[my host]
Last login: Sat Aug 22 17:47:47 2020 from 1.20.171.54
mgnewman@[my host] [~]#

パスワードなしでMacにSSHで接続できるため、SSHがPiで動作することを知っています。

pi@raspsky:~/.ssh $ ssh [email protected]
Last login: Sun Aug 23 06:11:14 2020 from 192.168.0.65.
MrMuscle:~ mnewman$

ホストは Known_hosts ファイルにあります。

pi@raspsky:~/.ssh $ ssh-keygen -F [my host]
# Host mgnewman.com found: line 1

このPiのSDカードは他のPi 4で複製されました。新しいPiで新しい公開/秘密鍵と新しいAuthorized_keysファイルとKnown_hostsファイルを作成しました。

私がどのように機能することができるかを知っている人はいますか?

簡単に言うと:

pi@raspsky:~/.ssh $ ssh mgnewman@[my host]
Connection closed by [my host IP] port 22

公開鍵がホストに送信されると、Piのデバッグ出力は次のようになります。

debug1: Offering public key: id_rsa RSA SHA256:4fUCtJQoMfxO/Za1goxtEjx5fyFq0tHgkus4jIhI7dE explicit
debug3: send packet: type 50
debug2: we sent a publickey packet, wait for reply
Connection closed by [myhost IP] port 22

以下は、Macのデバッグ出力と同じ行です。

debug1: Offering public key: /Users/mnewman/.ssh/id_rsa RSA SHA256:2RluaUDGj/vNTMBi9DD1nEHT/Ets+qwbdvo+E7DsKS0
debug3: send packet: type 50
debug2: we sent a publickey packet, wait for reply
debug3: receive packet: type 60
debug1: Server accepts key: /Users/mnewman/.ssh/id_rsa RSA SHA256:2RluaUDGj/vNTMBi9DD1nEHT/Ets+qwbdvo+E7DsKS0
debug1: Authentication succeeded (publickey).
Authenticated to [myhost] ([my host IP]:22).
debug1: channel 0: new [client-session]

完全な詳細出力は次のとおりです。

pi@raspsky:~/.ssh $ ssh -vvv mgnewman@[my host]
OpenSSH_7.9p1 Raspbian-10+deb10u2, OpenSSL 1.1.1d  10 Sep 2019
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug2: resolving "[my host]" port 22
debug2: ssh_connect_direct
debug1: Connecting to [my host] [[my host IP]] port 22.
debug1: Connection established.
debug1: identity file /home/pi/.ssh/id_rsa type 0
debug1: identity file /home/pi/.ssh/id_rsa-cert type -1
debug1: identity file /home/pi/.ssh/id_dsa type -1
debug1: identity file /home/pi/.ssh/id_dsa-cert type -1
debug1: identity file /home/pi/.ssh/id_ecdsa type -1
debug1: identity file /home/pi/[my host].ssh/id_ecdsa-cert type -1
debug1: identity file /home/pi/.ssh/id_ed25519 type -1
debug1: identity file /home/pi/.ssh/id_ed25519-cert type -1
debug1: identity file /home/pi/.ssh/id_xmss type -1
debug1: identity file /home/pi/.ssh/id_xmss-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_7.9p1 Raspbian-10+deb10u2
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.3
debug1: match: OpenSSH_5.3 pat OpenSSH_5* compat 0x0c000002
debug2: fd 3 setting O_NONBLOCK
debug1: Authenticating to [my host]:22 as 'mgnewman'
debug3: hostkeys_foreach: reading file "/home/pi/.ssh/known_hosts"
debug3: record_hostkey: found key type RSA in file /home/pi/.ssh/known_hosts:1
debug3: load_hostkeys: loaded 1 keys from [my host]
debug3: order_hostkeyalgs: prefer hostkeyalgs: [email protected],[email protected],[email protected],rsa-sha2-512,rsa-sha2-256,ssh-rsa
debug3: send packet: type 20
debug1: SSH2_MSG_KEXINIT sent
debug3: receive packet: type 20
debug1: SSH2_MSG_KEXINIT received
debug2: local client KEXINIT proposal
debug2: KEX algorithms: curve25519-sha256,[email protected],ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group14-sha256,diffie-hellman-group14-sha1,ext-info-```
debug2: host key algorithms: [email protected],[email protected],[email protected],rsa-sha2-512,rsa-sha2-256,ssh-rsa,[email protected],[email protected],[email protected],[email protected],ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ssh-ed25519
debug2: ciphers ctos: [email protected],aes128-ctr,aes192-ctr,aes256-ctr,[email protected],[email protected]
debug2: ciphers stoc: [email protected],aes128-ctr,aes192-ctr,aes256-ctr,[email protected],[email protected]
debug2: MACs ctos: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: MACs stoc: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: compression ctos: none,[email protected],zlib
debug2: compression stoc: none,[email protected],zlib
debug2: languages ctos:
debug2: languages stoc:
debug2: first_kex_follows 0
debug2: reserved 0
debug2: peer server KEXINIT proposal
debug2: KEX algorithms: diffie-hellman-group-exchange-sha256
debug2: host key algorithms: ssh-rsa,ssh-dss
debug2: ciphers ctos: aes256-ctr,aes192-ctr,aes128-ctr
debug2: ciphers stoc: aes256-ctr,aes192-ctr,aes128-ctr
debug2: MACs ctos: hmac-sha2-512,hmac-sha2-256,hmac-ripemd160,[email protected]
debug2: MACs stoc: hmac-sha2-512,hmac-sha2-256,hmac-ripemd160,[email protected]
debug2: compression ctos: none,[email protected]
debug2: compression stoc: none,[email protected]
debug2: languages ctos:
debug2: languages stoc:
debug2: first_kex_follows 0
debug2: reserved 0
debug1: kex: algorithm: diffie-hellman-group-exchange-sha256
debug1: kex: host key algorithm: ssh-rsa
debug1: kex: server->client cipher: aes128-ctr MAC: hmac-sha2-256 compression: none
debug1: kex: client->server cipher: aes128-ctr MAC: hmac-sha2-256 compression: none
debug3: send packet: type 34
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(2048<8192<8192) sent
debug3: receive packet: type 31
debug1: got SSH2_MSG_KEX_DH_GEX_GROUP
debug2: bits set: 4114/8192
debug3: send packet: type 32
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug3: receive packet: type 33
debug1: got SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Server host key: ssh-rsa SHA256:zvfdYBMDWtOFnGjLosCOjO9MNKNaLHVcYNJSg6Wx428
debug3: hostkeys_foreach: reading file "/home/pi/.ssh/known_hosts"
debug3: record_hostkey: found key type RSA in file /home/pi/.ssh/known_hosts:1
debug3: load_hostkeys: loaded 1 keys from [my host]
debug3: hostkeys_foreach: reading file "/home/pi/.ssh/known_hosts"
debug3: record_hostkey: found key type RSA in file /home/pi/.ssh/known_hosts:2
debug3: load_hostkeys: loaded 1 keys from [my host IP]
debug1: Host '[my host]' is known and matches the RSA host key.
debug1: Found key in /home/pi/.ssh/known_hosts:1
debug2: bits set: 4034/8192
debug3: send packet: type 21
debug2: set_newkeys: mode 1
debug1: rekey after 4294967296 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug3: receive packet: type 21
debug1: SSH2_MSG_NEWKEYS received
debug2: set_newkeys: mode 0
debug1: rekey after 4294967296 blocks
debug1: Will attempt key: /home/pi/.ssh/id_rsa RSA SHA256:4fUCtJQoMfxO/Za1goxtEjx5fyFq0tHgkus4jIhI7dE
debug1: Will attempt key: /home/pi/.ssh/id_dsa
debug1: Will attempt key: /home/pi/.ssh/id_ecdsa
debug1: Will attempt key: /home/pi/.ssh/id_ed25519
debug1: Will attempt key: /home/pi/.ssh/id_xmss
debug2: pubkey_prepare: done
debug3: send packet: type 5
debug3: receive packet: type 6
debug2: service_accept: ssh-userauth
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug3: send packet: type 50
debug3: receive packet: type 51
debug1: Authentications that can continue: publickey,password,keyboard-interactive
debug3: start over, passed a different list publickey,password,keyboard-interactive
debug3: preferred gssapi-keyex,gssapi-with-mic,publickey,keyboard-interactive,password
debug3: authmethod_lookup publickey
debug3: remaining preferred: keyboard-interactive,password
debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Offering public key: /home/pi/.ssh/id_rsa RSA SHA256:4fUCtJQoMfxO/Za1goxtEjx5fyFq0tHgkus4jIhI7dE
debug3: send packet: type 50
debug2: we sent a publickey packet, wait for reply
Connection closed by [my host IP] port 22

ベストアンサー1

ここで何が起こっているのか分かりません。 rsaを動作させることができず、ecdsaを試してみるかと思いました。キーペアを生成し、公開ecdsaキーをホストのauthorized_keysファイルにコピーしました。 SSHを使用して接続しようとしましたが、うまくいきました。

pi@raspsky:~/.ssh $ ssh -i /home/pi/.ssh/id_ecdsa mgnewman@[myhost].com
Last login: Sun Aug 23 23:53:26 2020 from 1.20.171.54
mgnewman@[myhost].com [~]# exit

それからrsaを再試行しました。それも働いた。

ecdsaキーを貼り付けたときにAuthorized_keysファイルを何とか「修正」しましたか?おそらく。

おすすめ記事