记一次重装ssh服务过程
重装ssh服务
卸载openssh
-
搜索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_64
、openssh-clients-8.0p1-4.el8_1.x86_64
、openssh-8.0p1-4.el8_1.x86_64
-
卸载
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
来进行卸载。 -
查看状态
service sshd status
返回结果:卸载成功
Redirecting to /bin/systemctl status sshd.service Unit sshd.service could not be found.
安装openssh
-
安装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!
-
查看状态
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(死亡)状态,接下来重启即可。 -
安装openssh客户端
其实安装了服务端后就可以链接了,但是如果我们使用的某些工具依赖于客户端就不得不安装了,比如scp命令是属于openssh-clients的。yum install openssh-clients
重启服务
-
重启
systemctl restart sshd.service
-
查看状体
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>
再看Active:
Active: active (running)
emmm~, 重装ssh完成。
贴个图:
参考博客:博客链接