SSH - 1s 在“进入交互式会话”时挂起(不是 DNS;可能与 SELinux 相关)

Mor*_*gon 9 ssh selinux centos centos6

我在 CentOS 6.7 上遇到了一个问题,其中 SSH 登录比该网络上的任何非 6.7 机器(例如 7.2、5.11)多 1 秒。在客户端运行调试显示“进入交互式会话”时挂起。

我用来进行此测试的命令time ssh <host> true来自我的笔记本电脑,使用 SSH 密钥。

我已经检查/修改的两件事是UseDNSand 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 毫秒
  • 比较我的 C6.7 机器 - 结果 64 位机器比我的 32 位机器快。也许这对某些人来说是一个“废话”时刻,但由于这些盒子都没有特别征税,我没想到会有 100-300 毫秒的差异。我能够在其中一台 64 位主机上打破 1 秒标记(850 毫秒)。32bit 最低为 1.085s

我要求太多了吗?对于 selinux-permissive 机器,10-1200ms 是可接受的登录时间吗?好奇其他人的基准是什么。

chu*_*utz 1

这可能不相关,但基于 IPA 的帐户已报告与 selinux 相关的缓慢问题: https: //access.redhat.com/discussions/3499951

该情况的解决方案是:

我查看了 SSSD 和 IPA 用户论坛,由于我的系统不使用 SELINUX,所以我继续将其添加到 sssd 配置中的域部分:

selinux_provider=none
Run Code Online (Sandbox Code Playgroud)

此后,如预期的那样,登录过程会立即进行。