サーバーにSSHで接続してkey_load_publicを取得しよう:No such file or directory error


43

Macからリモートサーバーへのパスワードなしのssh接続を作成しました。それは動作しました!

ssh -vvv username@my_ip
OpenSSH_7.2p2, LibreSSL 2.4.1
debug1: Reading configuration data /Users/Me/.ssh/config
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 20: Applying options for *
debug1: /etc/ssh/ssh_config line 53: Applying options for *
debug2: resolving "my_ip" port 22
debug2: ssh_connect_direct: needpriv 0
debug1: Connecting to my_ip [my_ip] port 22.
debug1: Connection established.
debug1: identity file /Users/Me/.ssh/id_rsa type 1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/Me/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/Me/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/Mes/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/Me/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/Me/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/Me/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/Me/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.2
ssh_exchange_identification: read: Connection reset by peer

.sshフォルダーを確認したところ、id_rsaそこにありましたが、他のフォルダーはありませんでした。エラーから、これらのファイルを何らかの形で作成する必要があるように見えますが、その方法はわかりません。

任意の助けをいただければ幸いです。


1
実際に問題はありますか?たとえば、実際にログインに失敗していますか?質問を編集して、最初の部分だけでなく、完全なデバッグ出力を含めることはできますか?
ケンスター

はい; 謝罪いたします!ログインできません-そして、以前の(そしておそらく最も重要な)行を中断していました。
エリック

回答:


51
debug1: key_load_public: No such file or directory

上記の行はエラーではありませんが、sshクライアントが別の公開キー(名前付き~/.ssh/id_rsa.pub)を見つけることができないという単純なデバッグログです。このファイルは、リモートサーバーに接続するために必要ではありませんが、役に立つ場合があります。

実際のエラー

ssh_exchange_identification: read: Connection reset by peer

サーバー構成のエラーを指します。サーバーは実行されていますが、SSH接続を受け入れられません。サーバーログで詳細を確認してください。同様の問題


そのリンクはとても役に立ちました。そして、それは(私は何かをテストしている間、私は私のサーバーにあまりにも多くの時間をssh'edていた)私は実際にブラックリストに載ったことが判明
エリック・

1
私の問題は、要塞ホストは、IPアドレスを変更していたknown_hosts私のMac上で誤っていた...それはあった@ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @...それはで行番号を示します~/.ssh/known_hosts:238。そのため、Macのknown_hostsファイルからその行(この場合は238)を削除し、正常に再接続しようとしました。
マルチェロデセールス

3

問題:要塞ホストIPの不一致 ~/.ssh/known_hosts

私が持っていたknown_hosts変更要塞のIPアドレスなどの古いファイルを...

$ ssh 10.82.49.24
ssh_exchange_identification: Connection closed by remote host

情報を提供しませんでした。詳細な出力を見ると、同じことがわかります。

$ ssh -v 10.82.49.24
OpenSSH_7.4p1, LibreSSL 2.5.0
debug1: Reading configuration data /Users/mdesales/.ssh/config
debug1: /Users/mdesales/.ssh/config line 1: Applying options for 10.82.*.*
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Executing proxy command: exec ssh -q -W 10.82.49.24:22 ec2-user@bastion-vpc-xxxxxx.config-yyyyyyy.com -i ~/.ssh/xxxconfig-xxxx.pem
debug1: key_load_public: No such file or directory
debug1: identity file ~/.ssh/xxxconfig-xxxx.pem
debug1: key_load_public: No such file or directory
debug1: identity file ~/.ssh/xxxconfig-xxxx.pem-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.4
debug1: permanently_drop_suid: 1647059022
ssh_exchange_identification: Connection closed by remote host

この時点で、要塞を介した別のホストへのプロキシであるため、要塞が問題であることがわかりました。

$ ssh ec2-user@bastion-vpc-xxxxxx.config-yyyyyyy.com -i ~/.ssh/xxxconfig-xxxx.pem
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that a host key has just been changed.
The fingerprint for the ECDSA key sent by the remote host is
SHA256:Z8X1UlIgQ94BKJ7NA/oQi7v0NL4IlFeO7Ou4j76Zphk.
Please contact your system administrator.
Add correct host key in /Users/mdesales/.ssh/known_hosts to get rid of this message.
Offending ECDSA key in /Users/mdesales/.ssh/known_hosts:238
ECDSA host key for ec2-user@bastion-vpc-xxxxxx.config-yyyyyyy.com has changed and you have requested strict checking.
Host key verification failed.

解決

238行目のエントリを削除することで問題は解決しました...要塞までsshでき、ホストまでsshできました。

$ vim /Users/mdesales/.ssh/known_hosts

$ ssh ec2-user@bastion-vpc-xxxxxx.config-yyyyyyy.com -i ~/.ssh/xxxconfig-xxxx.pem
The authenticity of host 'ec2-user@bastion-vpc-xxxxxx.config-yyyyyyy.com (34.x.x.y)' can't be established.
ECDSA key fingerprint is SHA256:Z8X1UlIgQ94BKJ7NA/oQi7v0NL4IlFeO7Ou4j76Zphk.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'ec2-user@bastion-vpc-xxxxxx.config-yyyyyyy.com -i ~/.ssh/xxxconfig-xxxx.pem,34.213.y.x' (ECDSA) to the list of known hosts.
********************************************************************************
This is a private computer system containing information that is proprietary
and confidential to the owner of the system.  Only individuals or entities
authorized by the owner of the system are allowed to access or use the system.
Any unauthorized access or use of the system or information is strictly
prohibited.

All violators will be prosecuted to the fullest extent permitted by law.
********************************************************************************
Last login: Wed Aug  2 20:35:55 2017 from 10.81.31.115
[ec2-user@ip-10-82-50-142 ~]$ 

1

今日私に起こった。

WLANを切断して再接続することで修正されました。はい、それは愚かに聞こえ、愚かですが、少なくとも1つのWLANでは、これは正当な理由もなく発生しました。


0

同じ問題、解決策をここに投稿してください

からIPを削除/etc/hosts.deny

nano /etc/hosts.deny
弊社のサイトを使用することにより、あなたは弊社のクッキーポリシーおよびプライバシーポリシーを読み、理解したものとみなされます。
Licensed under cc by-sa 3.0 with attribution required.