ssh-copy-id の後でも、サーバーはまだパスワードを要求します。

ssh-copy-id の後でも、サーバーはまだパスワードを要求します。

ssh-copy-idを使用してSSH公開鍵をサーバーにコピーしましたが、サーバーはまだパスワードを要求します。 sshフォルダ内のファイルの権限を確認しましたが、そのファイルはユーザーのみが読み取ることができます。また、sshd_configファイルを確認しましたが、PasswordAuthentication行はyesで終わります。サーバーでAuthorized_keysファイルを確認しましたが、キーはid_rsa.pubにある私のキーと一致します。

私は走る

ssh -i <path_to_key> <myusername@host> -vvv

これは私が経験しているエラーの一部です(StackExchangeではすべてのエラーを追加できません)。

OpenSSH_7.4p1, OpenSSL 1.0.2k-fips  26 Jan 2017
.....
debug1: Connecting to <host> port 22.
debug1: Connection established.
debug1: identity file id_rsa type 1
debug1: key_load_public: No such file or directory
debug1: identity file id_rsa-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.4
debug1: Remote protocol version 2.0, remote software version OpenSSH_7.4
debug1: match: OpenSSH_7.4 pat OpenSSH* compat 0x04000000
debug2: fd 3 setting O_NONBLOCK
debug1: Authenticating to <host>:22 as <myusername>
debug3: hostkeys_foreach: reading file "/users/studs/bsc/2016/orelhaz/.ssh/known_hosts"
debug3: record_hostkey: found key type ECDSA in file /users/studs/bsc/2016/orelhaz/.ssh/known_hosts:119
debug3: load_hostkeys: loaded 1 keys from <host>
debug3: order_hostkeyalgs: prefer hostkeyalgs: [email protected],[email protected],[email protected],ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521
.......
debug3: hostkeys_foreach: reading file "/users/studs/bsc/2016/orelhaz/.ssh/known_hosts"
debug3: record_hostkey: found key type ECDSA in file /users/studs/bsc/2016/orelhaz/.ssh/known_hosts:119
debug3: load_hostkeys: loaded 1 keys from <host>
debug3: hostkeys_foreach: reading file "/users/studs/bsc/2016/orelhaz/.ssh/known_hosts"
debug3: record_hostkey: found key type ECDSA in file /users/studs/bsc/2016/orelhaz/.ssh/known_hosts:119
debug3: load_hostkeys: loaded 1 keys from 132.72.44.112
debug1: Host <host> is known and matches the ECDSA host key.
debug1: Found key in /users/studs/bsc/2016/orelhaz/.ssh/known_hosts:119
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
......
debug3: start over, passed a different list publickey,gssapi-keyex,gssapi-with-mic,password
debug3: preferred gssapi-keyex,gssapi-with-mic,publickey,keyboard-interactive,password
debug3: authmethod_lookup gssapi-keyex
debug3: remaining preferred: gssapi-with-mic,publickey,keyboard-interactive,password
debug3: authmethod_is_enabled gssapi-keyex
debug1: Next authentication method: gssapi-keyex
debug1: No valid Key exchange context
debug2: we did not send a packet, disable method
...........
No Kerberos credentials available (default cache: KEYRING:persistent:8108)

debug1: Unspecified GSS failure.  Minor code may provide more information
No Kerberos credentials available (default cache: KEYRING:persistent:8108)

debug2: we did not send a packet, disable method
debug3: authmethod_lookup publickey
debug3: remaining preferred: keyboard-interactive,password
debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Offering RSA public key: id_rsa
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,gssapi-keyex,gssapi-with-mic,password
debug2: we did not send a packet, disable method
debug3: authmethod_lookup password
debug3: remaining preferred: ,password
debug3: authmethod_is_enabled password
debug1: Next authentication method: password

ありがとうございます。

ベストアンサー1

正しいキーファイル仕様を使用していますか?上記のデバッグログを私と比較してみてください。

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/user/.ssh/id_rsa RSA SHA256:6wZNjCyUdVXcrf05PJaayPZ0iB/0052zDvA+luvO0JM
debug3: send packet: type 50
debug2: we sent a publickey packet, wait for reply
debug3: receive packet: type 60
debug1: Server accepts key: /home/user/.ssh/id_rsa RSA SHA256:6wZNjCyUdVXcrf05PJaayPZ0iB/0052zDvA+luvO0JM
debug3: sign_and_send_pubkey: RSA SHA256:6wZNjCyUdVXcrf05PJaayPZ0iB/0052zDvA+luvO0JM
debug3: sign_and_send_pubkey: signing using ssh-rsa SHA256:6wZNjCyUdVXcrf05PJaayPZ0iB/0052zDvA+luvO0JM
debug3: send packet: type 50
debug3: receive packet: type 52
debug1: Authentication succeeded (publickey).

提供された公開鍵が単純なファイル名ではなく、フルパス(作成され実際に存在する場所)を指定するのがわかります。ローカル設定(キーワードIdentityFile:)を確認してください。

おすすめ記事