質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
公開鍵認証

公開鍵認証とは、公開鍵と秘密鍵の2つの鍵の組を利用する、SSHで利用される認証方式です。

CentOS

CentOSは、主にRed Hat Enterprise Linux(RHEL)をベースにした、フリーのソフトウェアオペレーティングシステムです。

SSH

SSH(Secure Shell)は、セキュアチャネルを通してデータを交換するためのネットワークプロトコルです。リモートサーバーへのコマンド実行やファイル転送を行う時に一般的に使用されます。

Linux

Linuxは、Unixをベースにして開発されたオペレーティングシステムです。日本では「リナックス」と呼ばれています。 主にWebサーバやDNSサーバ、イントラネットなどのサーバ用OSとして利用されています。 上位500のスーパーコンピュータの90%以上はLinuxを使用しています。 携帯端末用のプラットフォームAndroidは、Linuxカーネル上に構築されています。

Q&A

解決済

1回答

4714閲覧

一般ユーザーで公開鍵認証ができない

pice

総合スコア409

公開鍵認証

公開鍵認証とは、公開鍵と秘密鍵の2つの鍵の組を利用する、SSHで利用される認証方式です。

CentOS

CentOSは、主にRed Hat Enterprise Linux(RHEL)をベースにした、フリーのソフトウェアオペレーティングシステムです。

SSH

SSH(Secure Shell)は、セキュアチャネルを通してデータを交換するためのネットワークプロトコルです。リモートサーバーへのコマンド実行やファイル転送を行う時に一般的に使用されます。

Linux

Linuxは、Unixをベースにして開発されたオペレーティングシステムです。日本では「リナックス」と呼ばれています。 主にWebサーバやDNSサーバ、イントラネットなどのサーバ用OSとして利用されています。 上位500のスーパーコンピュータの90%以上はLinuxを使用しています。 携帯端末用のプラットフォームAndroidは、Linuxカーネル上に構築されています。

0グッド

0クリップ

投稿2021/11/10 11:33

編集2021/11/10 11:38

Conoha VPSのCentOS Stream 8 のVPSで、一般ユーザーでの公開鍵認証ができません。
一般ユーザーで公開鍵認証を使用してSSHログインするを参考にしましたが、Permission denied (publickey,gssapi-keyex,gssapi-with-mic)と出てしまいます。
ちなみに、vオプションのログはこのようになっておりました。

powershell

1OpenSSH_for_Windows_8.1p1, LibreSSL 3.0.2 2debug3: Failed to open file:C:/Users/fufl/.ssh/config error:2 3debug3: Failed to open file:C:/ProgramData/ssh/ssh_config error:2 4debug2: resolve_canonicalize: hostname xxx.xx.xx.xxx is address 5debug2: ssh_connect_direct 6debug1: Connecting to xxx.xx.xx.xxx [xxx.xx.xx.xxx] port xx. 7debug1: Connection established. 8debug3: Failed to open file:C:/Users/fufl/.ssh/id_rsa.pub error:2 9debug1: identity file C:\Users\fufl/.ssh/id_rsa type -1 10debug3: Failed to open file:C:/Users/fufl/.ssh/id_rsa-cert error:2 11debug3: Failed to open file:C:/Users/fufl/.ssh/id_rsa-cert.pub error:2 12debug1: identity file C:\Users\fufl/.ssh/id_rsa-cert type -1 13debug3: Failed to open file:C:/Users/fufl/.ssh/id_dsa error:2 14debug3: Failed to open file:C:/Users/fufl/.ssh/id_dsa.pub error:2 15debug1: identity file C:\Users\fufl/.ssh/id_dsa type -1 16debug3: Failed to open file:C:/Users/fufl/.ssh/id_dsa-cert error:2 17debug3: Failed to open file:C:/Users/fufl/.ssh/id_dsa-cert.pub error:2 18debug1: identity file C:\Users\fufl/.ssh/id_dsa-cert type -1 19debug3: Failed to open file:C:/Users/fufl/.ssh/id_ecdsa error:2 20debug3: Failed to open file:C:/Users/fufl/.ssh/id_ecdsa.pub error:2 21debug1: identity file C:\Users\fufl/.ssh/id_ecdsa type -1 22debug3: Failed to open file:C:/Users/fufl/.ssh/id_ecdsa-cert error:2 23debug3: Failed to open file:C:/Users/fufl/.ssh/id_ecdsa-cert.pub error:2 24debug1: identity file C:\Users\fufl/.ssh/id_ecdsa-cert type -1 25debug3: Failed to open file:C:/Users/fufl/.ssh/id_ed25519 error:2 26debug3: Failed to open file:C:/Users/fufl/.ssh/id_ed25519.pub error:2 27debug1: identity file C:\Users\fufl/.ssh/id_ed25519 type -1 28debug3: Failed to open file:C:/Users/fufl/.ssh/id_ed25519-cert error:2 29debug3: Failed to open file:C:/Users/fufl/.ssh/id_ed25519-cert.pub error:2 30debug1: identity file C:\Users\fufl/.ssh/id_ed25519-cert type -1 31debug3: Failed to open file:C:/Users/fufl/.ssh/id_xmss error:2 32debug3: Failed to open file:C:/Users/fufl/.ssh/id_xmss.pub error:2 33debug1: identity file C:\Users\fufl/.ssh/id_xmss type -1 34debug3: Failed to open file:C:/Users/fufl/.ssh/id_xmss-cert error:2 35debug3: Failed to open file:C:/Users/fufl/.ssh/id_xmss-cert.pub error:2 36debug1: identity file C:\Users\fufl/.ssh/id_xmss-cert type -1 37debug1: Local version string SSH-2.0-OpenSSH_for_Windows_8.1 38debug1: Remote protocol version 2.0, remote software version OpenSSH_8.0 39debug1: match: OpenSSH_8.0 pat OpenSSH* compat 0x04000000 40debug2: fd 3 setting O_NONBLOCK 41debug1: Authenticating to xxx.xx.xx.xxx:xx as 'fufl' 42debug3: hostkeys_foreach: reading file "C:\Users\fufl/.ssh/known_hosts" 43debug3: record_hostkey: found key type ECDSA in file C:\Users\fufl/.ssh/known_hosts:2 44debug3: load_hostkeys: loaded 1 keys from xxx.xx.xx.xxx 45debug3: Failed to open file:C:/Users/fufl/.ssh/known_hosts2 error:2 46debug3: Failed to open file:C:/ProgramData/ssh/ssh_known_hosts error:2 47debug3: Failed to open file:C:/ProgramData/ssh/ssh_known_hosts2 error:2 48debug3: order_hostkeyalgs: prefer hostkeyalgs: ecdsa-sha2-nistp256-cert-v01@openssh.com,ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp521-cert-v01@openssh.com,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521 49debug3: send packet: type 20 50debug1: SSH2_MSG_KEXINIT sent 51debug3: receive packet: type 20 52debug1: SSH2_MSG_KEXINIT received 53debug2: local client KEXINIT proposal 54debug2: KEX algorithms: curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group14-sha256,diffie-hellman-group14-sha1,ext-info-c 55debug2: host key algorithms: ecdsa-sha2-nistp256-cert-v01@openssh.com,ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp521-cert-v01@openssh.com,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ssh-ed25519-cert-v01@openssh.com,rsa-sha2-512-cert-v01@openssh.com,rsa-sha2-256-cert-v01@openssh.com,ssh-rsa-cert-v01@openssh.com,ssh-ed25519,rsa-sha2-512,rsa-sha2-256,ssh-rsa 56debug2: ciphers ctos: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com 57debug2: ciphers stoc: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com 58debug2: MACs ctos: umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1 59debug2: MACs stoc: umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1 60debug2: compression ctos: none,zlib@openssh.com,zlib 61debug2: compression stoc: none,zlib@openssh.com,zlib 62debug2: languages ctos: 63debug2: languages stoc: 64debug2: first_kex_follows 0 65debug2: reserved 0 66debug2: peer server KEXINIT proposal 67debug2: KEX algorithms: curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1 68debug2: host key algorithms: rsa-sha2-512,rsa-sha2-256,ssh-rsa,ecdsa-sha2-nistp256,ssh-ed25519 69debug2: ciphers ctos: aes256-gcm@openssh.com,chacha20-poly1305@openssh.com,aes256-ctr,aes256-cbc,aes128-gcm@openssh.com,aes128-ctr,aes128-cbc 70debug2: ciphers stoc: aes256-gcm@openssh.com,chacha20-poly1305@openssh.com,aes256-ctr,aes256-cbc,aes128-gcm@openssh.com,aes128-ctr,aes128-cbc 71debug2: MACs ctos: hmac-sha2-256-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha2-256,hmac-sha1,umac-128@openssh.com,hmac-sha2-512 72debug2: MACs stoc: hmac-sha2-256-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha2-256,hmac-sha1,umac-128@openssh.com,hmac-sha2-512 73debug2: compression ctos: none,zlib@openssh.com 74debug2: compression stoc: none,zlib@openssh.com 75debug2: languages ctos: 76debug2: languages stoc: 77debug2: first_kex_follows 0 78debug2: reserved 0 79debug1: kex: algorithm: curve25519-sha256 80debug1: kex: host key algorithm: ecdsa-sha2-nistp256 81debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none 82debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none 83debug3: send packet: type 30 84debug1: expecting SSH2_MSG_KEX_ECDH_REPLY 85debug3: receive packet: type 31 86debug1: Server host key: ecdsa-sha2-nistp256 SHA256:XX... 87debug3: hostkeys_foreach: reading file "C:\Users\fufl/.ssh/known_hosts" 88debug3: record_hostkey: found key type ECDSA in file C:\Users\fufl/.ssh/known_hosts:2 89debug3: load_hostkeys: loaded 1 keys from xxx.xx.xx.xxx 90debug3: Failed to open file:C:/Users/fufl/.ssh/known_hosts2 error:2 91debug3: Failed to open file:C:/ProgramData/ssh/ssh_known_hosts error:2 92debug3: Failed to open file:C:/ProgramData/ssh/ssh_known_hosts2 error:2 93debug1: Host 'xxx.xx.xx.xxx' is known and matches the ECDSA host key. 94debug1: Found key in C:\Users\fufl/.ssh/known_hosts:2 95debug3: send packet: type 21 96debug2: set_newkeys: mode 1 97debug1: rekey out after 134217728 blocks 98debug1: SSH2_MSG_NEWKEYS sent 99debug1: expecting SSH2_MSG_NEWKEYS 100debug3: receive packet: type 21 101debug1: SSH2_MSG_NEWKEYS received 102debug2: set_newkeys: mode 0 103debug1: rekey in after 134217728 blocks

Windows10からログインしようとしています。

ちなみにSSH Keyを登録するの方ではログインまで行えました。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

yukky1201

2021/11/11 04:39

Windows側の鍵保存ディレクトリは下記ですがちゃんと存在していますか C:/Users/fufl/.ssh/
pice

2021/11/13 12:54

ありがとうございます。存在しています。
guest

回答1

0

ベストアンサー

まずは下記を確認してみてはどうでしょうか?
それでも、解決しなければ、その確認結果を質問に追記するとさらに回答が集まりやすいかと思います。

可能性
・鍵やディレクトリのアクセス権が間違っている
・鍵のペアが間違っている

確認点
・サーバ側のログに何が出ているか
・サーバ側に置いたファイルの権限が適切か
・クライアント側の秘密鍵の権限が適切か

参考
https://teratail.com/questions/16932
https://qiita.com/youcune/items/2f427979403771f2e03a

また、質問文にデバッグ表示だけでなく、エラーが出たときに実行したコマンドとエラーの表示も記載すると分かりやすいですね。
お試しの環境では、sshコマンドを使ったと思いますが、どんなオプション付きで実行したか分かりません。

投稿2021/11/11 00:50

sukekeke0

総合スコア331

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

pice

2021/11/13 12:53

ありがとうございました。結果的に何が悪いか特定には至りませんでしたが、サーバー側でssh-keygen -m pemとして鍵を作成し、秘密鍵をクライアント側でTeratermから貼り付けして、サーバー側のディレクトリ、ファイルを適切な権限にすることで認証させることができるようになりました。細かく確認点等教えて頂きありがとうございました。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問