リモートユーザーのホームフォルダが/homeの代わりに/home2にある場合、パスワードのないSSH(ssh-copy-id)は機能しません。

リモートユーザーのホームフォルダが/homeの代わりに/home2にある場合、パスワードのないSSH(ssh-copy-id)は機能しません。

クライアントからサーバーにパスワードのないSSHを設定しています。

user1とという2人のユーザーがいますuser2。クライアントとサーバーの両方にuser1ホームフォルダがあります。/home/user1これは、コマンドを使用してアカウントを作成するときのデフォルトフォルダですuseradd user1

クライアントとサーバーの両方にuser2/home2/user2にホームフォルダがあります。これはコマンドを使用してユーザーを作成することによって行われます useradd -m -d /home2/user2 user2。その理由は、/home2より大きな16TBディスクにインストールし、ユーザー2のホームフォルダにより多くの記憶領域を提供したかったからです。

すべての提案に基づいて設定しました。/home2、、/home2/user2および/home2/user2/.ssh正しい700権限を設定しました。

結局のところ、パスワードなしのSSHはuser1クライアントからサーバーとして機能しますが、クライアントuser2からサーバーに要求してssh-keygen使用ssh-copy-idした後でもパスワードを要求することがわかりました。user2

これは私を混乱させる。これは、ホームフォルダが別の場所(たとえば)にuser2配置されなければならず、配置できないことを意味しますか?残念ながら、私のフォルダはわずか100 GBのため、より多くのスペースが必要です。/home/user2/home2/user2/homeuser2

追加情報 要求に応答して/var/log/messagesクライアントで自動ログインが実行された後、サーバーの ssh ログ () を調べました。ログには次のように表示されます。

Jan 20 09:42:55 SERVER dbus-daemon[2502]: [system] Activating service name='org.fedoraproject.SetroubleshootPrivileged' requested by ':1.39048' (uid=977 pid=2794759 comm="/usr/libexec/platform-python -Es /usr/sbin/setroub" label="system_u:system_r:setroubleshootd_t:s0") (using servicehelper)
Jan 20 09:42:55 SERVER dbus-daemon[2502]: [system] Successfully activated service 'org.fedoraproject.SetroubleshootPrivileged'
Jan 20 09:42:58 SERVER setroubleshoot[2794759]: SELinux is preventing /usr/sbin/sshd from read access on the file authorized_keys. For complete SELinux messages run: sealert -l 6b9fec5b-5b03-460b-8199-393d5863256b
Jan 20 09:42:58 SERVER setroubleshoot[2794759]: SELinux is preventing /usr/sbin/sshd from read access on the file authorized_keys.#012#012*****  Plugin catchall_labels (83.8 confidence) suggests   *******************#012#012If you want to allow sshd to have read access on the authorized_keys file#012Then you need to change the label on authorized_keys#012Do#012# semanage fcontext -a -t FILE_TYPE 'authorized_keys'#012where ...`

この問題を解決するのに役立ちます。

ベストアンサー1

サーバーはどのLinuxディストリビューションを使用し、SELinuxを使用しますか(確認sestatus)?

その場合は、次の作業も実行する必要があります。

semanage fcontext -a -t home_root_t '/home2'
semanage fcontext -a -t user_home_dir_t '/home2/[^/]+'
semanage fcontext -a -t user_home_t '/home2/[^/]+/.+'
restorecon -rv /home2

/home2実際のユーザーのホームディレクトリとその下のユーザーファイルに適切なSELinuxラベルを割り当てます/home2/<username>

(例タグはRHEL9用です。以前のバージョンのSELinuxではタグ構造が多少異なる場合があります。わからない場合は、ls -ldZ /home; ls -lZ /home既存のタグを確認して/home一致するようにタグを調整してください/home2。)

おすすめ記事