Selinux निजी कुंजी के साथ कनेक्शन स्वीकार नहीं करता है

Nov 26 2020

मुझे निम्न समस्या है:

मैंने SElinux स्थापित किया, अपने उपयोगकर्ता को unconfined_rsudo विशेषाधिकारों के साथ मैप किया और SSH कनेक्शन की अनुमति दी, लेकिन मैं लागू करने के बाद मोड अब sshऔर निजी कुंजी के साथ लॉग इन नहीं कर सकता ।

जब मैं sshअपने साथ जुड़ने की कोशिश करता हूं:

client_loop: send disconnect: Broken pipe

यह विन्यास है जो मैंने किया था:

echo "myuser_user ALL=(ALL) TYPE=sysadm_t ROLE=system_r /bin/sh " > /etc/sudoers.d/myuser_user

getsebool -a | grep ssh

allow_ssh_keysign --> on
fenced_can_ssh --> off
sftpd_write_ssh_home --> off
ssh_sysadm_login --> on
ssh_use_gpg_agent --> off

पूर्ण एसई लिनक्स विन्यास मैंने जोड़ा है, शायद डिबग के लिए मदद कर सकता है ...

semanage user -a -r s0-s0:c0.c1023 -R "unconfined_r system_r" ubuntu_user_u

cp /etc/selinux/default/contexts/users/unconfined_u /etc/selinux/default/contexts/users/ubuntu_user_u

semanage login -a -s ubuntu_user_u -rs0:c0.c1023 ubuntu

echo "ubuntu ALL=(ALL) TYPE=system_sudo_t ROLE=system_r /bin/sh " > /etc/sudoers.d/ubuntu

chcon -R -v system_u:object_r:system_sudo_t:s0 /home/ubuntu/.ssh/

यहां /var/log/audit.log जो ssh के साथ लॉग इन करने पर उत्पन्न होता है:

type=USER_AVC msg=audit(1606521919.331:151): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:kernel_t:s0 msg='avc:  denied  { start } for auid=n/a uid=0 gid=0 path="/run/systemd/transient/session-8.scope" cmdline="/lib/systemd/systemd-logind" scontext=system_u:system_r:kernel_t:s0 tcontext=system_u:object_r:systemd_unit_t:s0 tclass=service permissive=0  exe="/lib/systemd/systemd" sauid=0 hostname=? addr=? terminal=?'
type=USER_START msg=audit(1606521919.823:152): pid=1163 uid=0 auid=1000 ses=8 subj=system_u:system_r:kernel_t:s0 msg='op=PAM:session_open acct="ubuntu" exe="/usr/sbin/sshd" hostname=15.170.168.139 addr=15.170.168.139 terminal=ssh res=failed'
type=CRED_ACQ msg=audit(1606521919.823:153): pid=1231 uid=0 auid=1000 ses=8 subj=system_u:system_r:kernel_t:s0 msg='op=PAM:setcred acct="ubuntu" exe="/usr/sbin/sshd" hostname=15.170.168.139 addr=15.170.168.139 terminal=ssh res=success'
type=CRED_DISP msg=audit(1606521919.831:154): pid=1163 uid=0 auid=1000 ses=8 subj=system_u:system_r:kernel_t:s0 msg='op=PAM:setcred acct="ubuntu" exe="/usr/sbin/sshd" hostname=15.170.168.139 addr=15.170.168.139 terminal=ssh res=success'

aud2allow -w -a | grep "ssh"

type=USER_AVC msg=audit(1606522579.718:169): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:kernel_t:s0 msg='avc:  denied  { start } for auid=n/a uid=0 gid=0 path="/lib/systemd/system/ssh.service" cmdline="" scontext=system_u:system_r:kernel_t:s0 tcontext=system_u:object_r:unlabeled_t:s0 tclass=service permissive=1  exe="/lib/systemd/systemd" sauid=0 hostname=? addr=? terminal=?'
type=USER_AVC msg=audit(1606522579.718:170): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:kernel_t:s0 msg='avc:  denied  { status } for auid=n/a uid=0 gid=0 path="/lib/systemd/system/ssh.service" cmdline="" scontext=system_u:system_r:kernel_t:s0 tcontext=system_u:object_r:unlabeled_t:s0 tclass=service permissive=1  exe="/lib/systemd/systemd" sauid=0 hostname=? addr=? terminal=?'
type=USER_AVC msg=audit(1606522673.346:192): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:kernel_t:s0 msg='avc:  denied  { start } for auid=n/a uid=0 gid=0 path="/lib/systemd/system/ssh.service" cmdline="" scontext=system_u:system_r:kernel_t:s0 tcontext=system_u:object_r:unlabeled_t:s0 tclass=service permissive=0  exe="/lib/systemd/systemd" sauid=0 hostname=? addr=? terminal=?'
type=USER_AVC msg=audit(1606522687.874:196): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:kernel_t:s0 msg='avc:  denied  { start } for auid=n/a uid=0 gid=0 path="/lib/systemd/system/ssh.service" cmdline="" scontext=system_u:system_r:kernel_t:s0 tcontext=system_u:object_r:unlabeled_t:s0 tclass=service permissive=1  exe="/lib/systemd/systemd" sauid=0 hostname=? addr=? terminal=?'
type=USER_AVC msg=audit(1606522687.878:198): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:kernel_t:s0 msg='avc:  denied  { status } for auid=n/a uid=0 gid=0 path="/lib/systemd/system/ssh.service" cmdline="" scontext=system_u:system_r:kernel_t:s0 tcontext=system_u:object_r:unlabeled_t:s0 tclass=service permissive=1  exe="/lib/systemd/systemd" sauid=0 hostname=? addr=? terminal=?'
type=AVC msg=audit(1606522853.067:220): avc:  denied  { relabelto } for  pid=1529 comm="chcon" name=".ssh" dev="nvme0n1p1" ino=256082 scontext=system_u:system_r:kernel_t:s0 tcontext=system_u:object_r:system_sudo_t:s0 tclass=dir permissive=1
type=USER_AVC msg=audit(1606527581.704:277): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:kernel_t:s0 msg='avc:  denied  { status } for auid=n/a uid=0 gid=0 path="/lib/systemd/system/ssh.service" cmdline="" scontext=system_u:system_r:kernel_t:s0 tcontext=system_u:object_r:unlabeled_t:s0 tclass=service permissive=1  exe="/lib/systemd/systemd" sauid=0 hostname=? addr=? terminal=?'
type=USER_AVC msg=audit(1606527582.256:278): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:kernel_t:s0 msg='avc:  denied  { start } for auid=n/a uid=0 gid=0 path="/lib/systemd/system/ssh.service" cmdline="" scontext=system_u:system_r:kernel_t:s0 tcontext=system_u:object_r:unlabeled_t:s0 tclass=service permissive=1  exe="/lib/systemd/systemd" sauid=0 hostname=? addr=? terminal=?'
type=USER_AVC msg=audit(1606527704.324:293): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:kernel_t:s0 msg='avc:  denied  { start } for auid=n/a uid=0 gid=0 path="/lib/systemd/system/ssh.service" cmdline="" scontext=system_u:system_r:kernel_t:s0 tcontext=system_u:object_r:unlabeled_t:s0 tclass=service permissive=0  exe="/lib/systemd/systemd" sauid=0 hostname=? addr=? terminal=?'
type=USER_AVC msg=audit(1606527713.724:297): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:kernel_t:s0 msg='avc:  denied  { start } for auid=n/a uid=0 gid=0 path="/lib/systemd/system/ssh.service" cmdline="" scontext=system_u:system_r:kernel_t:s0 tcontext=system_u:object_r:unlabeled_t:s0 tclass=service permissive=1  exe="/lib/systemd/systemd" sauid=0 hostname=? addr=? terminal=?'
type=USER_AVC msg=audit(1606527713.724:298): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:kernel_t:s0 msg='avc:  denied  { status } for auid=n/a uid=0 gid=0 path="/lib/systemd/system/ssh.service" cmdline="" scontext=system_u:system_r:kernel_t:s0 tcontext=system_u:object_r:unlabeled_t:s0 tclass=service permissive=1  exe="/lib/systemd/systemd" sauid=0 hostname=? addr=? terminal=?'
type=AVC msg=audit(1606567016.248:483): avc:  denied  { relabelfrom } for  pid=10828 comm="restorecon" name=".ssh" dev="nvme0n1p1" ino=256082 scontext=system_u:system_r:kernel_t:s0 tcontext=system_u:object_r:system_sudo_t:s0 tclass=dir permissive=0
type=AVC msg=audit(1606567026.156:487): avc:  denied  { relabelfrom } for  pid=10830 comm="restorecon" name=".ssh" dev="nvme0n1p1" ino=256082 scontext=system_u:system_r:kernel_t:s0 tcontext=system_u:object_r:system_sudo_t:s0 tclass=dir permissive=1

aud2allow -w -a | grep "सामान्य"

type=AVC msg=audit(1606522853.063:219): avc:  denied  { associate } for  pid=1529 comm="chcon" name="authorized_keys" dev="nvme0n1p1" ino=256083 scontext=system_u:object_r:system_sudo_t:s0 tcontext=system_u:object_r:fs_t:s0 tclass=filesystem permissive=1
type=AVC msg=audit(1606522853.063:219): avc:  denied  { relabelto } for  pid=1529 comm="chcon" name="authorized_keys" dev="nvme0n1p1" ino=256083 scontext=system_u:system_r:kernel_t:s0 tcontext=system_u:object_r:system_sudo_t:s0 tclass=file permissive=1
type=AVC msg=audit(1606567016.248:484): avc:  denied  { relabelfrom } for  pid=10828 comm="restorecon" name="authorized_keys" dev="nvme0n1p1" ino=256083 scontext=system_u:system_r:kernel_t:s0 tcontext=system_u:object_r:system_sudo_t:s0 tclass=file permissive=0
type=AVC msg=audit(1606567026.156:488): avc:  denied  { relabelfrom } for  pid=10830 comm="restorecon" name="authorized_keys" dev="nvme0n1p1" ino=256083 scontext=system_u:system_r:kernel_t:s0 tcontext=system_u:object_r:system_sudo_t:s0 tclass=file permissive=1

कोई मदद कर सकता है?

जवाब

telcoM Nov 28 2020 at 20:39

यहां पहला ऑडिट लॉग संदेश है, जो बेहतर पठनीयता के लिए कई लाइनों में विभाजित है:

type=USER_AVC msg=audit(1606521919.331:151): pid=1 uid=0 auid=4294967295 ses=4294967295 \
subj=system_u:system_r:kernel_t:s0 \
msg='avc:  denied  { start } for auid=n/a uid=0 gid=0 \
path="/run/systemd/transient/session-8.scope" \
cmdline="/lib/systemd/systemd-logind" \
scontext=system_u:system_r:kernel_t:s0 \
tcontext=system_u:object_r:systemd_unit_t:s0 \
tclass=service permissive=0  \
exe="/lib/systemd/systemd" \
sauid=0 hostname=? addr=? terminal=?'

प्रकार है USER_AVC, इसलिए यह SELinux चेक विशेष रूप से किया गया था क्योंकि उपयोगकर्ता-अंतरिक्ष कोड ने इसका अनुरोध किया था। तो यह ट्रिगर किया उपयोगकर्ता-अंतरिक्ष कार्यक्रम स्पष्ट रूप से SELinux का समर्थन करता है।

यह pid=1इंगित करता है कि यह चेक सिस्टम की प्राथमिक initप्रक्रिया के लिए किया गया था , जो systemdइस मामले में स्पष्ट रूप से है।

subj=दायर है system_u:system_r:kernel_tतो, systemdसवाल में प्रक्रिया जाहिरा तौर पर गिरी के डिफ़ॉल्ट SELinux संदर्भ में शुरू किया गया था।

path=और cmdline=क्षेत्रों से संकेत मिलता है कि systemdउपयोगकर्ता सत्र गुंजाइश है, जो प्रति-उपयोगकर्ता की मेजबानी करेगा शुरू करने की प्रक्रिया में जाहिरा तौर पर था systemdइस प्रयोक्ता के लिए सेवाओं, और इस उपयोगकर्ता के सभी नियमित प्रक्रियाओं।

ऐसा करने से scontext=system_u:system_r:kernel_t:s0लक्ष्य के संदर्भ tcontext=system_u:object_r:systemd_unit_t:s0में निष्पादन योग्य शुरू करने के लिए स्रोत SELinux संदर्भ ( ) और लक्ष्य संदर्भ ( ) के बीच की रेखा को पार करने की आवश्यकता होगी /lib/systemd/systemd। लेकिन msg=क्षेत्र के अनुसार , इसे अस्वीकार कर दिया गया था।

यह एक ऐसी प्रणाली में एक बहुत ही मौलिक ऑपरेशन है जो उपयोग कर रहा है systemd, इसलिए एक अच्छी तरह से बनाई गई डिफ़ॉल्ट नीति निश्चित रूप से इसे कवर करने की संभावना होगी। मैं उम्मीद करूंगा कि उत्पादन-ग्रेड प्रणाली इस तरह विफलताओं का उत्पादन न करे। इससे मुझे लगता है कि आपकी वर्तमान SELinux नीति पूरी तरह से उपयोग के लिए अद्यतित नहीं हो सकती है systemd

चूंकि आपके SELinux कॉन्फ़िगरेशन में शामिल हैं ubuntu_user_u, यह सुझाव देता है कि आप उबंटू या इसके कुछ व्युत्पन्न का उपयोग कर रहे हैं।

क्या आप निश्चित हैं कि आपके द्वारा उपयोग की जाने वाली SELinux नीति आपके द्वारा उपयोग किए जा रहे वितरण की सटीक रिलीज़ के लिए अद्यतित है? यदि सिस्टम को एक प्रमुख रिलीज़ से दूसरे apt full-upgradeया इसी तरह के साथ अपग्रेड किया गया है , तो कुछ अतिरिक्त कदम हो सकते हैं जिन्हें आपको अपडेटेड पॉलिसी मॉड्यूल फ़ाइलों से सक्रिय SELinux पॉलिसी को पुनर्जीवित करने के लिए लेना होगा।