小编Mor*_*gon的帖子

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

我在 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 毫秒。 …

ssh selinux centos centos6

9
推荐指数
1
解决办法
1484
查看次数

标签 统计

centos ×1

centos6 ×1

selinux ×1

ssh ×1