重裝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完成。
貼個圖:
參考博客:博客鏈接