zoukankan      html  css  js  c++  java
  • ssh问题

    ssh 登录慢

    ssh远程连接服务器及其缓慢,重启重装sshd无济于事

    用ssh -vvv  发登录慢是卡在下面这步:

    debug1: Entering interactive session.

    后发现在执行机上systemd-logind导致cpu 100%的问题,使得登录异常缓慢,并且消耗资源。

    原因
    systemd-logind主要功能是为每一个登陆session创建一个systemd角度的cgroup管理对象,更方便对session使用cgroup,在实际场景中没有什么用处,关闭不会影响正常ssh登陆
    在有crond任务时,触发systemd-logind回收不及时的bug
    解决办法
    关闭或重启systemd-logind

    systemctl stop systemd-logind

    ssh取消超时断开

     编辑/etc/ssh/sshd_config

    ClientAliveInterval 60
    ClientAliveCountMax 3

    编辑/etc/profile

    添加 TMOUT=0

    为0就是设置不超时

    免密登录

    [root@master ~]# ssh-keygen -t rsa  #生成密钥,连续三个回车即可,除非想二次认证,就是使用ssh免密登录时再用密码认证
    Generating public/private rsa key pair.
    Enter file in which to save the key (/root/.ssh/id_rsa): 
    Created directory '/root/.ssh'.
    Enter passphrase (empty for no passphrase): 
    Enter same passphrase again: 
    Your identification has been saved in /root/.ssh/id_rsa.
    Your public key has been saved in /root/.ssh/id_rsa.pub.
    The key fingerprint is:
    10:a2:a8:c6:01:f4:21:94:2e:f7:e3:d5:17:4e:a7:53 root@master
    The key's randomart image is:
    +--[ RSA 2048]----+
    |++... .          |
    |.oo... .         |
    |o...  .          |
    |+.o    .  o E    |
    |o+ .   .So =     |
    |.   o . . =      |
    |   . o   . .     |
    |    .            |
    |                 |
    +-----------------+
    
    [root@master ~]# scp .ssh/id_rsa.pub root@192.168.92.130:/root/.ssh/authorized_keys #将生成的id_rsa.pub传到 B服务器下
    The authenticity of host '192.168.92.130 (192.168.92.130)' can't be established.
    ECDSA key fingerprint is fe:45:19:51:dc:97:92:55:5e:5f:28:cd:b1:28:59:08.
    Are you sure you want to continue connecting (yes/no)? yes
    Warning: Permanently added '192.168.92.130' (ECDSA) to the list of known hosts.
    root@192.168.92.130's password: 
    Permission denied, please try again.
    root@192.168.92.130's password: 
    id_rsa.pub                                                                                                     100%  393     0.4KB/s   00:00    
    [root@master ~]# ssh 192.168.92.130   #登录测试,发现已经能直接连接
    Last failed login: Thu Mar 26 23:30:22 PDT 2020 from 192.168.92.128 on ssh:notty
    There was 1 failed login attempt since the last successful login.
    Last login: Thu Mar 26 22:54:46 2020 from 192.168.92.1
    [root@slave-02 ~]# 
  • 相关阅读:
    关于struts2的checkboxlist、select等标签发生could not be resolved as a collection/array/map/enumeration/iterator type异常的记录
    ajax Session失效如何跳转到登录页面
    将默认首页设置成index.do的方法
    tomcat应用转到weblogic上时的问题
    MyEclipse 8.5整合Git,并在Github上发布项目(转)
    C++ 类设计核查表
    编程书籍
    并发模型
    C++ AOP手法
    编程 网上资源平台
  • 原文地址:https://www.cnblogs.com/zphqq/p/10646946.html
Copyright © 2011-2022 走看看