web-dev-qa-db-ja.com

SSHデバッグメッセージでIDファイルタイプは何を意味しますか?

次のコマンドを使用して、SSH接続をデバッグしています。

ssh -vT [email protected]

そして、私は次のメッセージを受け取りました:

debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 48: Applying options for *
debug2: ssh_connect_direct: needpriv 0
debug1: Connecting to smilescooter.com port 22.
debug1: Connection established.
debug1: identity file /Users/jerry/.ssh/id_rsa type 0
debug1: key_load_public: No such file or directory
debug1: identity file /Users/jerry/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/jerry/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/jerry/.ssh/id_dsa-cert type -1
debug1: identity file /Users/jerry/.ssh/id_ecdsa type 2
debug1: key_load_public: No such file or directory
debug1: identity file /Users/jerry/.ssh/id_ecdsa-cert type -1
...
debug3: hostkeys_foreach: reading file "/Users/jerry/.ssh/known_hosts"
debug3: record_hostkey: found key type ECDSA in file /Users/jerry/.ssh/known_hosts:19
debug3: load_hostkeys: loaded 1 keys from smilescooter.com
debug3: order_hostkeyalgs: prefer hostkeyalgs: [email protected],[email protected],[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

幸いなことに、問題は修正されましたが、「IDファイルfile_routetypen」という意味です。ここでnは-1,0,1,2 ...

debugの後のnumber(1/2/3 ..)は、各デバッグ行の先頭で何を意味しますか?

私はこれについてグーグルで結果を見つけたかどうか、ここでは尋ねません。 googleにはSSH問題のデバッグに関する多くの結果がありますが、ここで尋ねた2つのことについて誰も話していないようです。

よろしくお願いします。

6
xczzhh

IDファイルは、単に秘密キー(または証明書)であり、通常はssh-keygenを実行して作成されます。これによりデフォルトでRSAキーが作成されますが、-tオプションを使用して変更できます。出力によると、RSAキーとECDSAキーがあります。

identity file type .../.ssh/id_* type <number>の数値は、 sshkey_types enum の整数値(ゼロベース)であり、-1はエラーを意味します(ほとんどのPOSIX関数と同様)。ファイル名にキータイプも含まれていることがわかります。

enum sshkey_types {
KEY_RSA, // id_rsa has type 0
KEY_DSA, // id_dsa has type 1, but as you have no id_dsa key file, -1 is used 
KEY_ECDSA, // id_ecdsa has type 2
...

エラーメッセージkey_load_public:No such file or directoryidentity file ... messages奇妙な、対応する公開鍵ファイルが削除されたようです。これらは、.pubサフィックスが追加された秘密鍵と同じファイル名を持ちます。 ssh-keygen -yを使用すると、公開キーを秘密キーから再生成できるため(明らかな理由でその逆はできません)、これは悲劇的ではありません。

デバッグ出力については、このニースで説明しています OpenSSHロギングに関するウィキブックスの記事 。要するに:debug [123]:内の数字:...行プレフィックスは、その背後のメッセージのデバッグレベルを示します。これは、コマンドラインで指定した-vsの数に対応します(最大3つ)。つまり、-vを設定すると、debug1メッセージが出力され、-vvを使用すると、debug1およびdebug2などが表示されます(debug3メッセージが表示されるのは少し奇妙です)ただし、単一の-vのみを指定しました)

6
Jakob

出力が示すように、「タイプn」はキータイプの内部IDです(RSA、ECDSA、ED25519など)。リストは sshkey.c で見ることができます。

同様に、debugの後のnはデバッグレベルです。示した出力は、-vvv、またはレベル3(最大)までのデバッグロギングのためです。したがって、debug1debug2、およびdebug3です。

両方の詳細は、一般にOpenSSH開発者(主にOpenBSD開発者)だけが使用するものなので、これが一般的に議論されるとは思わないでしょう。

2
muru