Distributions
› Ubuntu
› Fedora
› CentOS
中文资源站
› 网易开源镜像站
shiyuu
V2EX  ›  Linux

Linux 接显示器终端登陆和 ssh 登录都超慢,但是帐户登陆进去后执行运行各种就很流程,如何排查?

  •  
  •   shiyuu · Oct 22, 2024 · 4092 views
    This topic created in 743 days ago, the information mentioned may be changed or developed.

    我们有一台主机 ssh 连接登录很慢,切换 root 权限也很慢 登陆后或者获取 root 权限之后操作各种命令查询执行各种程序都很流畅没有问题

    把软件的开机应用进程全停了,重启了服务器依然是这样

    人跑到在机房接显示器用键盘操作输入账号登陆也是一样很慢要等很久 bmc 看了服务器也没有什么告警,所有的硬盘都扫描了一遍坏道都是正常的

    这种情况还要怎么排查?

    26 replies  •  2024-10-23 18:15:39 +08:00
    zzsong
    zzsong
    Oct 22, 2024
    1
    我也遇到过 ssh 连接非常慢的问题,后来发现是因为 DNS 配置问题,把 DNS 地址改成网关地址就好了。
    defunct9
    defunct9
    Oct 22, 2024
    2
    UseDNS no
    crownor
    crownor
    Oct 22, 2024
    3
    在 /etc/ssh/sshd_config 下 102 行左右,取消掉 UseDNS no 的注释就好,简单粗暴
    cJ8SxGOWRH0LSelC
    cJ8SxGOWRH0LSelC
    Oct 22, 2024
    4
    @crownor #3 学到了, 这是什么原理?
    shiyuu
    shiyuu
    OP
    Oct 22, 2024
    5
    @crownor 早就已经是 no 了,还是一样的情况
    shiyuu
    shiyuu
    OP
    Oct 22, 2024
    6
    @crownor 而且这个 sshd_config 的配置是对 ssh 。注意看我的描述,我连接在机房服务器上显示器登陆也是这样
    ho121
    ho121
    Oct 22, 2024 via Android
    7
    zhangmingyu
    zhangmingyu
    Oct 22, 2024
    8
    是不是用户 profile 中有些脚本卡住了?
    anytk
    anytk
    Oct 22, 2024
    9
    以前 LXC 中遇到过类似的,是 systemd-logind 的问题,你可以登陆一个用 top 看占用,另外登陆一个会话看看。

    ssh/su 都会卡很久很久,只不过 lxc 中解决很粗暴 :`systemctl mask systemd-logind`
    julyclyde
    julyclyde
    Oct 22, 2024
    10
    如果符合下列所有条件:
    腾讯资产/腾讯云
    centos7/tencentos2 系列其中的较早期版本
    没有安装“铁将军”

    有可能遇到因为频繁使用 cron 任务做 ps 检测而导致的 systemd-logind 的 session 数据累积的问题
    guanzhangzhang
    guanzhangzhang
    Oct 22, 2024
    11
    strace 下 sshd ,然后你开 ssh 看看,以及登录加载和不加载 profile 对比看看
    maclanelf134
    maclanelf134
    Oct 22, 2024
    12
    https://blog.csdn.net/lixialv/article/details/107670539
    前两天改过,一个是 UseDns 改 no 还有一个是 GSSAPIAuthentication 改 no
    skyrim61
    skyrim61
    Oct 22, 2024
    13
    同样遇到过. 远程 ssh 登录 就会卡在 连接, 要等很久才能进去
    skyrim61
    skyrim61
    Oct 22, 2024
    14
    Connecting to 10.20.xxx.xx:22...
    Connection established.
    To escape to local shell, press 'Ctrl+Alt+]'.
    blessingsi
    blessingsi
    Oct 22, 2024
    15
    ssh -vvv 看下 debug 信息
    zed1018
    zed1018
    Oct 22, 2024
    16
    终端登录、su 也很慢我怀疑是 pam 相关的模块的问题,建议看看日志里有没有相关的。
    yaytohkay
    yaytohkay
    Oct 22, 2024
    17
    tcpdump 抓包看看呢
    shiyuu
    shiyuu
    OP
    Oct 22, 2024
    18
    @anytk top 看了一下,另一台登陆的时候 ssh 进程 cpu 使用率飙到 100%,切 root 的时候 su 进程也会飙到 100%,systemd-logind 进程没有什么变化。日志 messages 里也没有什么特别的错误
    shiyuu
    shiyuu
    OP
    Oct 22, 2024
    19
    大概找到原因了,是/var/log/btmp 文件太大了,我把他重命名再登陆就不卡了

    superrichman
    superrichman
    Oct 22, 2024
    20
    profile 和 rc 文件里面有脏东西
    superrichman
    superrichman
    Oct 22, 2024
    21
    噗,你这是被爆破了吧,登录记录这么大
    shiyuu
    shiyuu
    OP
    Oct 22, 2024
    22
    @superrichman #21 是给别的部门开了 sftp 拉日志,没想到他们他们搞出这么多登陆失败
    callmebigfaceman
    callmebigfaceman
    Oct 22, 2024
    23
    64G 的 btmp ,这是万万没想到的。😏
    raycheung
    raycheung
    Oct 23, 2024
    24
    这原因真的是又长见识了😮
    amiwrong123
    amiwrong123
    Oct 23, 2024 via Android
    25
    @shiyuu
    又学到了😂
    justdoit123
    justdoit123
    Oct 23, 2024
    26
    有时候在我司一些 “没人疼” 的测试服务器上,会看到几个 G 大小的 log 文件~~~~~
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1473 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 76ms · UTC 22:34 · PVG 06:34 · LAX 14:34 · JFK 17:34
    ♥ Do have faith in what you're doing.