特定のユーザーに対してSSH公開鍵が機能しません。

特定のユーザーに対してSSH公開鍵が機能しません。

私のシステムには、user1とuser2という2人のユーザーがいます。

各Authorized_keysのmd5sumは次のとおりです。

de092f77fb4a3be2cd8864c5f9961149  user1/.ssh/authorized_keys
de092f77fb4a3be2cd8864c5f9961149  user2/.ssh/authorized_keys

以下は、各.sshフォルダの一覧です。

user1/.ssh/:
total 8
drwx------. 2 user1 user1   28 Mar 16 12:11 .
drwxrwx---. 5 user1 user1 4096 Mar 16 12:11 ..
-rw-------. 1 user1 user1  412 Mar 16 12:11 authorized_keys

user2/.ssh/:
total 4
drwx------. 2 user2 user2  28 Mar 16 11:37 .
drwx------. 3 user2 user2  90 Mar 16 11:38 ..
-rw-------. 1 user2 user2 412 Mar 16 11:37 authorized_keys

それぞれの認証は次のとおりです。

ユーザー1:

debug1: Next authentication method: publickey
debug1: Offering RSA public key: /Users/me/.ssh/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

ユーザー2:

debug1: Next authentication method: publickey
debug1: Offering RSA public key: /Users/me/.ssh/id_rsa
debug3: send_pubkey_test
debug3: send packet: type 50
debug2: we sent a publickey packet, wait for reply
debug3: receive packet: type 60
debug1: Server accepts key: pkalg ssh-rsa blen 279

/etc/passwd:

user1:x:1001:1001::/home/user1:/bin/bash
user2:x:1004:1004::/home/user2:/bin/bash

つまり、user2を使用して公開鍵を使用してログインできますが、user1は使用できません。パスワードを使用したログインは両方に適しています。なぜこれがあるユーザーには機能しますが、他のユーザーには機能しないのかわかりません。 user1と連携するには公開鍵認証が必要です(sshagentを介してスクリプトを実行するには公開鍵認証を使用する必要があるため)。

これがうまくいかない理由をどこで見つけるべきかわかりません。すべてのオンラインガイドには、キー、権限の確認、および再生成が必要です。しかし、上記の内容はすべて正確に見えます。 /etc/ssh フォルダに user1 への言及が見つかりませんでした。

パスワードを入力するとログインできます。

データを匿名化するためにユーザー名を編集しました。

ベストアンサー1

問題は、グループが書き込みを許可するホームフォルダの権限にあります。

おすすめ記事