私は仮想ubuntuサーバーを実行していますが、通常は接続に問題はありません。しかし、過去4日間で2回connection closed by remote Host
を取得しました。私は複数のアカウントを持っていますが、それぞれで同じ結果が得られました。再起動後、再度ログインできました。
これは私がログインできないときに得られるものです
ssh -vvv user@Host_name
OpenSSH_7.2p2 Ubuntu-4ubuntu2.1, OpenSSL 1.0.2g 1 Mar 2016
debug1: Reading configuration data /home/user/.ssh/config
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug2: resolving "Host_name" port 22
debug2: ssh_connect_direct: needpriv 0
debug1: Connecting to Host_name [IP.IP.IP.IP] port 22.
debug1: Connection established.
debug1: key_load_public: No such file or directory
debug1: identity file /home/user/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/user/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.2p2 Ubuntu-4ubuntu2.1
debug1: Remote protocol version 2.0, remote software version OpenSSH_6.6.1p1 Ubuntu-2ubuntu2.8
debug1: match: OpenSSH_6.6.1p1 Ubuntu-2ubuntu2.8 pat OpenSSH_6.6.1* compat 0x04000000
debug2: fd 3 setting O_NONBLOCK
debug1: Authenticating to Host_name:22 as 'user'
debug3: hostkeys_foreach: reading file "/home/user/.ssh/known_hosts"
debug3: record_hostkey: found key type ECDSA in file /home/user/.ssh/known_hosts:23
debug3: load_hostkeys: loaded 1 keys from Host_name
debug3: order_hostkeyalgs: prefer hostkeyalgs: [email protected],[email protected],ecdsa-sha2-nistp521-c
[email protected],ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521
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: [email protected],ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,dif
fie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,ext-info-c
debug2: Host key algorithms: [email protected],[email protected],[email protected]
m,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,[email protected],[email protected],ssh-ed25519,rsa-sha2-512,r
sa-sha2-256,ssh-rsa
debug2: ciphers ctos: [email protected],aes128-ctr,aes192-ctr,aes256-ctr,[email protected],[email protected],aes128-cbc,aes192-c
bc,aes256-cbc,3des-cbc
debug2: ciphers stoc: [email protected],aes128-ctr,aes192-ctr,aes256-ctr,[email protected],[email protected],aes128-cbc,aes192-c
bc,aes256-cbc,3des-cbc
debug2: MACs ctos: [email protected],[email protected],[email protected],[email protected],hmac-sha1-etm@openssh.
com,[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: MACs stoc: [email protected],[email protected],[email protected],[email protected],hmac-sha1-etm@openssh.
com,[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: [email protected],ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,dif
fie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1
debug2: Host key algorithms: ssh-rsa,ssh-dss,ecdsa-sha2-nistp256,ssh-ed25519
debug2: ciphers ctos: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,[email protected],[email protected],[email protected]
om,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,[email protected]
debug2: ciphers stoc: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,[email protected],[email protected],[email protected]
om,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,[email protected]
debug2: MACs ctos: [email protected],[email protected],[email protected],[email protected],[email protected],h
[email protected],[email protected],[email protected],[email protected],hmac-md5,hmac-sha1,umac-64@openss
h.com,[email protected],hmac-sha2-256,hmac-sha2-512,hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96
debug2: MACs stoc: [email protected],[email protected],[email protected],[email protected],[email protected],h
[email protected],[email protected],[email protected],[email protected],hmac-md5,hmac-sha1,umac-64@openss
h.com,[email protected],hmac-sha2-256,hmac-sha2-512,hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96
debug2: compression ctos: none,[email protected]
debug2: compression stoc: none,[email protected]
debug2: languages ctos:
debug2: languages stoc:
debug2: first_kex_follows 0
debug1: kex: algorithm: [email protected]
debug1: kex: Host key algorithm: ecdsa-sha2-nistp256
debug1: kex: server->client cipher: [email protected] MAC: <implicit> compression: none
debug1: kex: client->server cipher: [email protected] MAC: <implicit> compression: none
debug3: send packet: type 30
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug3: receive packet: type 31
debug1: Server Host key: ecdsa-sha2-nistp256 SHA256:eJMfyQRvAyYtV7qR3eZHoHJv4um5NlkZ6lqOM5+3/x8
debug3: hostkeys_foreach: reading file "/home/user/.ssh/known_hosts"
debug3: record_hostkey: found key type ECDSA in file /home/user/.ssh/known_hosts:23
debug3: load_hostkeys: loaded 1 keys from Host
debug3: hostkeys_foreach: reading file "/home/user/.ssh/known_hosts"
debug3: record_hostkey: found key type ECDSA in file /home/user/.ssh/known_hosts:24
debug3: load_hostkeys: loaded 1 keys from IP.IP.IP.IP
debug1: Host 'Host' is known and matches the ECDSA Host key.
debug1: Found key in /home/user/.ssh/known_hosts:23
debug3: send packet: type 21
debug2: set_newkeys: mode 1
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug3: receive packet: type 21
debug2: set_newkeys: mode 0
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS received
debug2: key: user@local (0x5587cbcb1630), agent
debug2: key: user@local (0x5587cbcaf4f0), agent
debug2: key: user@local (0x5587cbcaf560), agent
debug2: key: user@local (0x5587cbcb1260), agent
debug2: key: user@local (0x5587cbcb12b0), agent
debug2: key: /home/user/.ssh/id_rsa ((nil))
debug2: key: /home/user/.ssh/id_dsa ((nil))
debug2: key: /home/user/.ssh/id_ecdsa ((nil))
debug2: key: /home/user/.ssh/id_ed25519 ((nil))
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: remaining preferred: keyboard-interactive,password
debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Offering RSA public key: user@local
debug3: send_pubkey_test
debug3: send packet: type 50
debug2: we sent a publickey packet, wait for reply
debug3: receive packet: type 51
debug1: Authentications that can continue: publickey,password
debug1: Offering RSA public key: user@local
debug3: send_pubkey_test
debug3: send packet: type 50
debug2: we sent a publickey packet, wait for reply
debug3: receive packet: type 51
debug1: Authentications that can continue: publickey,password
debug1: Offering RSA public key: user@local
debug3: send_pubkey_test
debug3: send packet: type 50
debug2: we sent a publickey packet, wait for reply
debug3: receive packet: type 60
debug1: Server accepts key: pkalg ssh-rsa blen 535
debug2: input_userauth_pk_ok: fp SHA256:sc7ESM4WTnxwcB1WLlNt0P34/j0U2c/SbDL2d9re7VA
debug3: sign_and_send_pubkey: RSA SHA256:sc7ESM4WTnxwcB1WLlNt0P34/j0U2c/SbDL2d9re7VA
debug3: send packet: type 50
debug3: receive packet: type 53
debug3: input_userauth_banner
System is booting up.
debug1: Authentication succeeded (publickey).
Authenticated to Host ([IP.IP.IP.IP]:22).
debug1: channel 0: new [client-session]
debug3: ssh_session2_open: channel_new: 0
debug2: channel 0: send open
debug3: send packet: type 90
debug1: Requesting [email protected]
debug3: send packet: type 80
debug1: Entering interactive session.
debug1: pledge: network
debug3: send packet: type 1
debug1: channel 0: free: client-session, nchannels 1
debug3: channel 0: status: The following connections are open:
#0 client-session (t3 r-1 i0/0 o0/0 fd 5/6 cc -1)
Connection to Host closed by remote Host.
Connection to Host closed.
Transferred: sent 4028, received 2672 bytes, in 0.0 seconds
Bytes per second: sent 45293985.3, received 30046059.8
debug1: Exit status -1
問題をトラブルシューティングするには
私は this 投稿をフォローして開きました
$(which sshd) -Ddp 10222
そして私はでログインすることができました
ssh -p 10222 user@Host
hosts.allow
またはhosts.deny
を使用していません。
Sshキーが関連付けられていないアカウントが1つあります。しかし、正しいパスワードを入力しても、同じエラーメッセージが表示されます。
/etc/ssh/sshd_config
で
#MaxStartups #is not used
Sshが正しく設定されていることを確認するために他にどのような手順を実行できますか。
「このメッセージは、クライアントがサーバーへのTCP接続を取得したが、SSHプロトコルが開始される前にサーバーがすぐにそれを閉じたことを意味します(ssh_exchange_identificationルーチンはバージョン文字列交換を実装します。最初のステップです)これは通常、接続を禁止するlibwrap
設定が原因で発生します。サーバーログを確認してください。これが問題である場合は、次のようなメッセージが表示されます。
_SSH1, OpenSSH sshd1[15092]: refused connect from 192.168.10.1
SSH2 sshd2[15085]: Denied connection from by 192.168.10.1 tcp wrappers.
_
libwrap (TCP-wrappers)
サポートを使用してSSHサーバーをコンパイルした場合は、サーバーホスト上のファイル_/etc/hosts.{allow,deny}
_のルールがSSHデーモンへの接続を許可していることを確認してください。たとえば、このようなエントリを使用すると、任意の送信元アドレスからsshdに接続できます。
_sshd sshd1 sshd2 : ALL : ALLOW
_
左側の名前は、実行中のデーモンの_argv[0]
_値である必要があるため、別の名前でsshdを呼び出した場合は、それを使用する必要があります。また、ルールは順序に依存するため、他のルールとそれらの相対的な配置によっては、指定したルールが機能しない場合があります。 libwrap
ルールの構文とセマンティクスの詳細については、hosts_access(5)
のマニュアルページを参照してください。」
参照: SSH FAQ
また、 serverfault のこのエントリを参照してください。非常に役立つ回答です。