Mor*_*gon 9 ssh selinux centos centos6
我在 CentOS 6.7 上遇到了一个问题,其中 SSH 登录比该网络上的任何非 6.7 机器(例如 7.2、5.11)多 1 秒。在客户端运行调试显示“进入交互式会话”时挂起。
我用来进行此测试的命令time ssh <host> true
来自我的笔记本电脑,使用 SSH 密钥。
我已经检查/修改的两件事是UseDNS
and GSSAPIAuthentication
,并且都被禁用。
我在不同的端口上启动了一个单独的守护进程,并打开了调试,并找到了发生短暂挂起的地方:
debug1: SELinux support enabled
debug3: ssh_selinux_setup_exec_context: setting execution context
{1s hang}
debug3: ssh_selinux_setup_exec_context: done
Run Code Online (Sandbox Code Playgroud)
SELinux 设置为“宽松”。我不确定为什么它甚至会为“设置上下文”而烦恼。有什么办法可以让这两者在不完全禁用 SELinux 的情况下更好地相处?我意识到 1s 并不多,但我使用这台特定的机器作为到带有 IP 白名单的主机的 SSH 网关(这是一台静态 IP 机器),并且它整天都在增加。
运行 strace 后,挂起更加细化:
22:16:05.445032 open("/selinux/user", O_RDWR|O_LARGEFILE) = 4 <0.000090>
22:16:05.445235 write(4, "unconfined_u:system_r:sshd_t:s0-s0:c0.c1023 unconfined_u", 56) = 56 <0.334742>
22:16:05.780128 read(4, "18\0unconfined_u:system_r:prelink_mask_t:s0-s0:c0.c1023\0unconfined_u:system_r:unconfined_mount_t:s0-s0:c0.c1023\0unconfined_u:system_r:abrt_helper_t:s0-s0:c0.c1023\0unconfined_u:system_r:oddjob_mkhomedir_t:s0-s0:c0.c1023\0unconfined_u:system_r:unconfined_notrans_t:s0-s0:c0.c1023\0unconfined_u:system_r:unconfined_execmem_t:s0-s0:c0.c1023\0unconfined_u:system_r:unconfined_java_t:s0-s0:c0.c1023\0unconfined_u:system_r:unconfined_mono_t:s0-s0:c0.c1023\0unconfined_u:system_r:chkpwd_t:s0-s0:c0.c1023\0unconfined_u:system_r:passwd_t:s0-s0:c0.c1023\0unconfined_u:system_r:updpwd_t:s0-s0:c0.c1023\0unconfined_u:system_r:mount_t:s0-s0:c0.c1023\0unconfined_u:system_r:rssh_t:s0-s0:c0.c1023\0unconfined_u:system_r:xauth_t:s0-s0:c0.c1023\0unconfined_u:system_r:unconfined_t:s0-s0:c0.c1023\0unconfined_u:system_r:openshift_t:s0-s0:c0.c1023\0unconfined_u:unconfined_r:oddjob_mkhomedir_t:s0-s0:c0.c1023\0unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023\0", 4095) = 929 <0.000079>
Run Code Online (Sandbox Code Playgroud)
仅写入就/selinux/user
需要 350 毫秒。
更新 1 - 我已经尝试过的事情:
semodule -d unconfined
- 这产生了积极影响,将登录时间减少了大约 500 毫秒。然而,我的 C7 和 C5.11 机器(我已经(重新)学习已禁用 SELinux)平均约 525 毫秒我要求太多了吗?对于 selinux-permissive 机器,10-1200ms 是可接受的登录时间吗?好奇其他人的基准是什么。
这可能不相关,但基于 IPA 的帐户已报告与 selinux 相关的缓慢问题: https: //access.redhat.com/discussions/3499951
该情况的解决方案是:
我查看了 SSSD 和 IPA 用户论坛,由于我的系统不使用 SELINUX,所以我继续将其添加到 sssd 配置中的域部分:
Run Code Online (Sandbox Code Playgroud)selinux_provider=none
此后,如预期的那样,登录过程会立即进行。