zoukankan      html  css  js  c++  java
  • 记一次重装ssh服务过程

    重装ssh服务

    卸载openssh

    1. 搜索openssh

      rpm -qa | grep ssh
      

      结果:

      openssh-clients-8.0p1-4.el8_1.x86_64
      libssh-0.8.5-2.el8.x86_64
      openssh-8.0p1-4.el8_1.x86_64
      openssh-server-8.0p1-4.el8_1.x86_64
      

      我们分别卸载上面的:openssh-server-8.0p1-4.el8_1.x86_64openssh-clients-8.0p1-4.el8_1.x86_64openssh-8.0p1-4.el8_1.x86_64

    2. 卸载

      rpm -e openssh-server-8.0p1-4.el8_1.x86_64
      #上面它返回了一个警告信息,不用管
      #warning: /etc/ssh/sshd_config saved as /etc/ssh/sshd_config.rpmsave
      rpm -e openssh-clients-8.0p1-4.el8_1.x86_64
      rpm -e openssh-8.0p1-4.el8_1.x86_64
      

      如果报错,可以使用yum remove替换上面的rpm -e来进行卸载。

    3. 查看状态

      service sshd status
      

      返回结果:卸载成功

      Redirecting to /bin/systemctl status sshd.service
      Unit sshd.service could not be found.
      

    安装openssh

    1. 安装openssh服务

      yum install -y openssh-server
      

      下载过程:

      Last metadata expiration check: 0:02:57 ago on Wed 03 Mar 2021 05:59:08 PM CST.
      Dependencies resolved.
      ===========================================================================================================================================================================================================================================================
       Package                                                          Arch                                                     Version                                                          Repository                                                Size
      ===========================================================================================================================================================================================================================================================
      Installing:
       openssh-server                                                   x86_64                                                   8.0p1-5.el8                                                      BaseOS                                                   484 k
      Installing dependencies:
       openssh                                                          x86_64                                                   8.0p1-5.el8                                                      BaseOS                                                   520 k
      
      Transaction Summary
      ===========================================================================================================================================================================================================================================================
      Install  2 Packages
      
      Total download size: 1.0 M
      Installed size: 2.8 M
      Downloading Packages:
      (1/2): openssh-8.0p1-5.el8.x86_64.rpm                                                                                                                                                                                      395 kB/s | 520 kB     00:01    
      (2/2): openssh-server-8.0p1-5.el8.x86_64.rpm                                                                                                                                                                               366 kB/s | 484 kB     00:01    
      -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
      Total                                                                                                                                                                                                                      759 kB/s | 1.0 MB     00:01     
      Running transaction check
      Transaction check succeeded.
      Running transaction test
      Transaction test succeeded.
      Running transaction
        Preparing        :                                                                                                                                                                                                                                   1/1 
        Running scriptlet: openssh-8.0p1-5.el8.x86_64                                                                                                                                                                                                        1/2 
        Installing       : openssh-8.0p1-5.el8.x86_64                                                                                                                                                                                                        1/2 
        Running scriptlet: openssh-server-8.0p1-5.el8.x86_64                                                                                                                                                                                                 2/2 
        Installing       : openssh-server-8.0p1-5.el8.x86_64                                                                                                                                                                                                 2/2 
        Running scriptlet: openssh-server-8.0p1-5.el8.x86_64                                                                                                                                                                                                 2/2 
        Verifying        : openssh-8.0p1-5.el8.x86_64                                                                                                                                                                                                        1/2 
        Verifying        : openssh-server-8.0p1-5.el8.x86_64                                                                                                                                                                                                 2/2 
      
      Installed:
        openssh-server-8.0p1-5.el8.x86_64                                                                                               openssh-8.0p1-5.el8.x86_64                                                                                              
      
      Complete!
      
    2. 查看状态

      service sshd status
      

      状态信息:

      Redirecting to /bin/systemctl status sshd.service
      ● sshd.service - OpenSSH server daemon
         Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled; vendor preset: enabled)
         Active: inactive (dead) since Wed 2021-03-03 17:53:07 CST; 9min ago
           Docs: man:sshd(8)
                 man:sshd_config(5)
       Main PID: 1061640 (code=exited, status=0/SUCCESS)
       .......
      

      可以看到上面的信息,证明已经安装成功,注意一个信息:Active: inactive (dead) ,即服务是dead(死亡)状态,接下来重启即可。

    3. 安装openssh客户端
      其实安装了服务端后就可以链接了,但是如果我们使用的某些工具依赖于客户端就不得不安装了,比如scp命令是属于openssh-clients的。

      yum install openssh-clients
      

    重启服务

    1. 重启

      systemctl restart sshd.service
      
    2. 查看状体

      service sshd status
      

      状态信息:

      Redirecting to /bin/systemctl status sshd.service
      ● sshd.service - OpenSSH server daemon
         Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled; vendor preset: enabled)
         Active: active (running) since Wed 2021-03-03 18:03:06 CST; 52min ago
           Docs: man:sshd(8)
                 man:sshd_config(5)
       Main PID: 1087117 (sshd)
          Tasks: 1 (limit: 11540)
         Memory: 3.6M
         CGroup: /system.slice/sshd.service
                 └─1087117 /usr/sbin/sshd -D -oCiphers=aes256-gcm@openssh.com,chacha20-poly1305@openssh.com,aes256-ctr,aes256-cbc,aes128-gcm@openssh.com,aes128-ctr,aes128-cbc -oMACs=hmac-sha2-256-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-512-etm@o>
      

      再看ActiveActive: active (running)

    emmm~, 重装ssh完成。

    贴个图:

    参考博客:博客链接

  • 相关阅读:
    asp.net mvc异常处理的不同方法
    获取计算机网络信息,包含IP,MAC
    MessageBox页面消息弹出框类
    centos7.4离线安装.NETCore3.1 环境
    .NET Core 3.0 WebApi 使用Swagger
    android隐藏apk方式以及apk之间的启动方式
    react native 更改项目包名
    react native windows下打包apk流程
    CentOS7下安装Redis
    EFCore配置多对多关系
  • 原文地址:https://www.cnblogs.com/langkyeSir/p/14476338.html
Copyright © 2011-2022 走看看