さくらのVPS上のcentOSへのパスワードログインを不可にし、ssh公開鍵認証接続でログインするように設定したいのですが、Permission deniedされてしまいます。
サーバーOS、クライアントOS双方の.sshディレクトリ、id_rsa、id_rsa.pub、authorized_keys等のpermissionの設定はchmodを実行し完了済みです。
原因がわからず困っています。どうぞよろしくお願いします。
以下デバッグ実行結果。
me@MacBookAir ~ % ssh -vi ~/.ssh/id_rsa vpsuser@xxx.xx.xx.xx OpenSSH_8.1p1, LibreSSL 2.7.3 debug1: Reading configuration data /etc/ssh/ssh_config debug1: /etc/ssh/ssh_config line 47: Applying options for * debug1: Connecting to xxx.xx.xx.xx [xxx.xx.xx.xx] port 22. debug1: Connection established. debug1: identity file /Users/me/.ssh/id_rsa type 0 debug1: identity file /Users/me/.ssh/id_rsa-cert type -1 debug1: Local version string SSH-2.0-OpenSSH_8.1 debug1: Remote protocol version 2.0, remote software version OpenSSH_7.4 debug1: match: OpenSSH_7.4 pat OpenSSH_7.0*,OpenSSH_7.1*,OpenSSH_7.2*,OpenSSH_7.3*,OpenSSH_7.4*,OpenSSH_7.5*,OpenSSH_7.6*,OpenSSH_7.7* compat 0x04000002 debug1: Authenticating to xxx.xx.xx.xx:22 as 'vpsuser' debug1: SSH2_MSG_KEXINIT sent debug1: SSH2_MSG_KEXINIT received debug1: kex: algorithm: curve25519-sha256 debug1: kex: host key algorithm: ecdsa-sha2-nistp256 debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none debug1: expecting SSH2_MSG_KEX_ECDH_REPLY debug1: Server host key: ecdsa-sha2-nistp256 SHA256:O5rjMSVgOtd9w9KDInCQPi2dE/SIczfZWci81fCeniQ debug1: Host 'xxx.xx.xx.xx' is known and matches the ECDSA host key. debug1: Found key in /Users/me/.ssh/known_hosts:1 debug1: rekey out after 134217728 blocks debug1: SSH2_MSG_NEWKEYS sent debug1: expecting SSH2_MSG_NEWKEYS debug1: SSH2_MSG_NEWKEYS received debug1: rekey in after 134217728 blocks debug1: Will attempt key: /Users/me/.ssh/id_rsa RSA SHA256:UBU5Zm+lmOkiTOCYv4QxjDiZzkFmmVKLIvM6g9i3jVo explicit debug1: SSH2_MSG_EXT_INFO received debug1: kex_input_ext_info: server-sig-algs=<rsa-sha2-256,rsa-sha2-512> debug1: SSH2_MSG_SERVICE_ACCEPT received debug1: Authentications that can continue: publickey debug1: Next authentication method: publickey debug1: Offering public key: /Users/me/.ssh/id_rsa RSA SHA256:UBU5Zm+lmOkiTOCYv4QxjDiZzkFmmVKLIvM6g9i3jVo explicit debug1: Authentications that can continue: publickey debug1: No more authentication methods to try. vpsuser@xxx.xx.xx.xx: Permission denied (publickey). me@MacBookAir ~ %
追記
yukky1201様
サーバーへ公開鍵を登録した手順は、
1.クライアントOS(Mac)でホームディレクトリに.sshディレクトリを作成
2..sshディレクトリにてssh-keygenを実行しキーペアを作成
3.サーバーOS(centOS)の一般ユーザー(vpsuser)のホームディレクトリに.sshディレクトリを作成
4.クライアントOSからscpでid_rsa.pubをauthorized_keysという名前でサーバーOS側の.sshに転送
5.必要なpermissionの設定をchmodで全て完了
という流れです。
angel_p_57様
permission不備の確認のため、パスワード認証を有効にしssh -vでのログイン実行しました。
以下のように表示されました。
me@MacBookAir ~ % ssh -v vpsuser@xxx.xx.xx.xx OpenSSH_8.1p1, LibreSSL 2.7.3 debug1: Reading configuration data /etc/ssh/ssh_config debug1: /etc/ssh/ssh_config line 47: Applying options for * debug1: Connecting to xxx.xx.xx.xx [xxx.xx.xx.xx] port 22. debug1: Connection established. debug1: identity file /Users/me/.ssh/id_rsa type 0 debug1: identity file /Users/me/.ssh/id_rsa-cert type -1 debug1: identity file /Users/me/.ssh/id_dsa type -1 debug1: identity file /Users/me/.ssh/id_dsa-cert type -1 debug1: identity file /Users/me/.ssh/id_ecdsa type -1 debug1: identity file /Users/me/.ssh/id_ecdsa-cert type -1 debug1: identity file /Users/me/.ssh/id_ed25519 type -1 debug1: identity file /Users/me/.ssh/id_ed25519-cert type -1 debug1: identity file /Users/me/.ssh/id_xmss type -1 debug1: identity file /Users/me/.ssh/id_xmss-cert type -1 debug1: Local version string SSH-2.0-OpenSSH_8.1 debug1: Remote protocol version 2.0, remote software version OpenSSH_7.4 debug1: match: OpenSSH_7.4 pat OpenSSH_7.0*,OpenSSH_7.1*,OpenSSH_7.2*,OpenSSH_7.3*,OpenSSH_7.4*,OpenSSH_7.5*,OpenSSH_7.6*,OpenSSH_7.7* compat 0x04000002 debug1: Authenticating to xxx.xx.xx.xx:22 as 'vpsuser' debug1: SSH2_MSG_KEXINIT sent debug1: SSH2_MSG_KEXINIT received debug1: kex: algorithm: curve25519-sha256 debug1: kex: host key algorithm: ecdsa-sha2-nistp256 debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none debug1: expecting SSH2_MSG_KEX_ECDH_REPLY debug1: Server host key: ecdsa-sha2-nistp256 SHA256:O5rjMSVgOtd9w9KDInCQPi2dE/SIczfZWci81fCeniQ debug1: Host 'xxx.xx.xx.xx' is known and matches the ECDSA host key. debug1: Found key in /Users/me/.ssh/known_hosts:1 debug1: rekey out after 134217728 blocks debug1: SSH2_MSG_NEWKEYS sent debug1: expecting SSH2_MSG_NEWKEYS debug1: SSH2_MSG_NEWKEYS received debug1: rekey in after 134217728 blocks debug1: Will attempt key: /Users/me/.ssh/id_rsa RSA SHA256:UBU5Zm+lmOkiTOCYv4QxjDiZzkFmmVKLIvM6g9i3jVo debug1: Will attempt key: /Users/me/.ssh/id_dsa debug1: Will attempt key: /Users/me/.ssh/id_ecdsa debug1: Will attempt key: /Users/me/.ssh/id_ed25519 debug1: Will attempt key: /Users/me/.ssh/id_xmss debug1: SSH2_MSG_EXT_INFO received debug1: kex_input_ext_info: server-sig-algs=<rsa-sha2-256,rsa-sha2-512> debug1: SSH2_MSG_SERVICE_ACCEPT received debug1: Authentications that can continue: publickey,password debug1: Next authentication method: publickey debug1: Offering public key: /Users/me/.ssh/id_rsa RSA SHA256:UBU5Zm+lmOkiTOCYv4QxjDiZzkFmmVKLIvM6g9i3jVo debug1: Authentications that can continue: publickey,password debug1: Trying private key: /Users/me/.ssh/id_dsa debug1: Trying private key: /Users/me/.ssh/id_ecdsa debug1: Trying private key: /Users/me/.ssh/id_ed25519 debug1: Trying private key: /Users/me/.ssh/id_xmss debug1: Next authentication method: password vpsuser@xxx.xx.xx.xx's password: debug1: Authentication succeeded (password). Authenticated to xxx.xx.xx.xx ([xxx.xx.xx.xx]:22). debug1: channel 0: new [client-session] debug1: Requesting no-more-sessions@openssh.com debug1: Entering interactive session. debug1: pledge: network debug1: client_input_global_request: rtype hostkeys-00@openssh.com want_reply 0 debug1: Remote: Ignored authorized keys: bad ownership or modes for directory /home/vpsuser/.ssh debug1: Sending environment. debug1: Sending env LANG = ja_JP.UTF-8 Last login: Fri May 1 14:26:51 2020 from softbank126147178223.bbtec.net SAKURA Internet [Virtual Private Server SERVICE] [vpsuser@tk2-212-15534 ~]$
また、ssh-keygen -y -f ~/.ssh/id_rsa を実行して、id_rsa.pubファイルと内容が一致するかを確認しましたが、きちんと一致しておりました。
Match条件について確認しましたが、sshd_configを見る限りそれでは無さそうです、、。
どうぞよろしくお願いします。
回答3件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2020/05/01 05:55
2020/05/01 07:44
2020/05/01 07:55