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

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

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

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

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

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