
IPでSSH経由で接続しようとしていますが、ログに次のエラーメッセージが表示されます。
Jun 5 11:36:50 thetemplate my-sshd[26346]: Accepted password for user1 from 172.80.1.2 port 34278 ssh2
Jun 5 11:36:50 thetemplate my-sshd[26346]: User child is on pid 27078
Jun 5 11:36:50 thetemplate my-sshd[27078]: ssh_selinux_change_context: setcon failed with Invalid argument
Jun 5 11:36:50 thetemplate my-sshd[27078]: Changed root directory to "/test//ssh/home/user1"
Jun 5 11:36:50 thetemplate my-sshd[26346]: error: ssh_selinux_setup_pty: security_compute_relabel: Invalid argument
~によると この回答my-sshd
、私は次のようにしてコンテキストを変更してみました。
chcon system_u:object_r:sshd_exec_t:s0 /test/bin/my-sshd
service sshd restart
/var/log/messages
SSHを実行すると、エラーメッセージが表示され続けます。
その間、ps -eZ | grep sshd
私はこれがmy-sshd
異なる文脈を持っていることを発見しました。/usr/sbin/sshd
unconfined_u:system_r:sshd_t:s0-s0:c0.c1023 24012 ? 00:00:00 sshd
unconfined_u:system_r:sshd_t:s0-s0:c0.c1023 24272 ? 00:00:00 sshd
unconfined_u:system_r:sshd_t:s0-s0:c0.c1023 29923 ? 00:00:00 sshd
unconfined_u:unconfined_r:unconfined_java_t:s0-s0:c0.c1023 32487 ? 00:00:00 my-sshd
これがこれらのエラーメッセージの原因かもしれませんか?では、どうすればよいですか?
編集する:
レベル 3 デバッグでは、setcon は次のコンテキストを設定できません。
debug3: ssh_selinux_change_context: setting context from 'unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023' to 'unconfined_u:unconfined_r:chroot_user_t:s0-s0:c0.c1023'
ssh_selinux_change_context: setcon failed with Invalid argument
このコンテキストの変更は、サーバーのルートディレクトリを変更する前に発生します。ルートディレクトリが変更され、サーバーにSSHで接続できるため、どの機能にも影響しません。これらのエラーメッセージは私の/var/log/messagesを複雑にします。 ssh_selinux_change_contextメソッドの呼び出しを避ける方法はありますか?このメソッドが正確にいつトリガーされるのかわかりません。解決策を特定するために他の助けをいただきありがとうございます。
答え1
コマンドの使用
audit2allow -w -a
出力の下部には問題を解決するためのlinuxコマンドがあります。