- 安裝telnet,切換為telnet登錄饶号,確保在安裝ssh時能穩(wěn)定連接
[root@localhost ~]# yum install xinetd telnet-server -y
[root@localhost ~]# systemctl enable xinetd
[root@localhost ~]# systemctl enable telnet.socket
[root@localhost ~]# systemctl start telnet.socket
[root@localhost ~]# systemctl start xinetd
#安裝相關(guān)依賴激率,編譯安裝必備
[root@localhost ~]# yum install -y gcc gcc-c++ glibc make autoconf pcre-devel pam-devel
[root@localhost ~]# yum install -y pam* zlib*
- 查看當(dāng)前版本
[root@localhost ~]# ssh -V
OpenSSH_8.0p1, OpenSSL 1.0.2r 26 Feb 2019
3.更新openssl
[root@localhost ~]# yum update openssl
4.安裝opebssh
[root@localhost ~]# systemctl status sshd #查看sshd
[root@localhost ~]# systemctl stop sshd #停止sshd
[root@localhost ~]# rm -rf /etc/ssh/ #清理配置文件
#查看當(dāng)前openssh
[root@localhost ~]# rpm -qa |grep openssh
openssh-clients-6.6.1p1-31.el7.x86_64
openssh-server-6.6.1p1-31.el7.x86_64
#刪除當(dāng)前openssh
[root@localhost ~]# yum erase -y openssh-clients openssh-server openssh
#安裝openssh
[root@localhost ~]# yum install -y pam-devel #安裝pam
[root@localhost ]# tar xf openssh-8.9p1.tar.gz #解壓openssh8.9
[root@localhost ]# cd openssh-8.9p1
#配置
./configure --prefix=/usr/ --sysconfdir=/etc/ssh --with-openssl-includes=/usr/local/include --with-ssl-dir=/usr/local/bin --with-zlib --with-md5-passwords --with-pam
## --prefix=/usr/ 這里還是指定一下安裝的目錄路徑;
#--sysconfdir=/etc/ssh 這里指定的配置文件的目錄路徑;
#--with-openssl-includes=/usr/local/include 看上面講一下;
# --with-ssl-dir=/usr/local/openssl 看上面講一下;后面參數(shù)不需要調(diào)整咳燕,寫上就可以啦
#安裝
make && make install
[root@localhost openssh-8.9p1]# echo $? 檢查,結(jié)果為0就好了
0
[root@localhost openssh-8.9p1]# cd contrib/redhat 在解壓的openssh目錄找到啟動文件
[root@localhost redhat]# ll
總用量 48
-rw-r--r-- 1 confluence confluence 58 2月 23 19:31 gnome-ssh-askpass.csh
-rw-r--r-- 1 confluence confluence 70 2月 23 19:31 gnome-ssh-askpass.sh
-rw-r--r-- 1 confluence confluence 30082 2月 23 19:31 openssh.spec
-rwxr-xr-x 1 confluence confluence 1721 2月 23 19:31 sshd.init
-rw-r--r-- 1 confluence confluence 277 2月 23 19:31 sshd.pam
[root@localhost redhat]# cp -a sshd.init /etc/init.d/sshd
cp:是否覆蓋"/etc/init.d/sshd"乒躺?#回車
#啟動ssh
[root@localhost redhat]# systemctl start sshd
Warning: sshd.service changed on disk. Run 'systemctl daemon-reload' to reload units. #警告了招盲,操作下
[root@localhost redhat]# systemctl daemon-reload #按照上面提示操作
[root@localhost redhat]# systemctl start sshd #啟動
#順便設(shè)置一下開機(jī)自動啟動
#常規(guī)的 systemctl 設(shè)置會給予一個提示,命令被重定向了嘉冒,那么就使用提示給的命令
[root@localhost redhat]# systemctl enable sshd
sshd.service is not a native service, redirecting to /sbin/chkconfig.
Executing /sbin/chkconfig sshd on
#再次設(shè)置開機(jī)啟動
#下面顯示2曹货、3、4讳推、5是on就可以顶籽,其數(shù)字代表啟動級別
[root@localhost redhat]# /sbin/chkconfig sshd on
[root@localhost redhat]# chkconfig --list sshd
注意:該輸出結(jié)果只顯示 SysV 服務(wù),并不包含原生 systemd 服務(wù)银觅。SysV 配置數(shù)據(jù)可能被原生 systemd 配置覆蓋礼饱。
如果您想列出 systemd 服務(wù),請執(zhí)行 'systemctl list-unit-files'。
欲查看對特定 target 啟用的服務(wù)請執(zhí)行
'systemctl list-dependencies [target]'究驴。
sshd 0:關(guān) 1:關(guān) 2:開 3:開 4:開 5:開 6:關(guān)
#配置允許root登錄
[root@localhost redhat]# vim /etc/ssh/sshd_config
#在文件中加入下面內(nèi)容
permitRootlogin yes
#重啟sshd
[root@localhost redhat]# systemctl restart sshd
[root@localhost redhat]# systemctl status sshd
● sshd.service - SYSV: OpenSSH server daemon
Loaded: loaded (/etc/rc.d/init.d/sshd; bad; vendor preset: enabled)
Active: active (running) since 四 2022-04-07 20:27:03 CST; 25s ago
Docs: man:systemd-sysv-generator(8)
Process: 25647 ExecStop=/etc/rc.d/init.d/sshd stop (code=exited, status=0/SUCCESS)
Process: 25650 ExecStart=/etc/rc.d/init.d/sshd start (code=exited, status=0/SUCCESS)
Main PID: 25656 (sshd)
CGroup: /system.slice/sshd.service
├─13677 sshd: root@notty
├─13679 /usr/libexec/sftp-server
├─13785 /usr/libexec/sftp-server
└─25656 sshd: /usr/sbin/sshd [listener] 0 of 10-100 startups
4月 07 20:27:03 localhost.localdomain systemd[1]: Starting SYSV: OpenSSH server daemon...
4月 07 20:27:03 localhost.localdomain sshd[25656]: Server listening on 0.0.0.0 port 22.
4月 07 20:27:03 localhost.localdomain sshd[25656]: Server listening on :: port 22.
4月 07 20:27:03 localhost.localdomain sshd[25650]: Starting sshd:[ 確定 ]
4月 07 20:27:03 localhost.localdomain systemd[1]: Started SYSV: OpenSSH server daemon.
#查看版本
[root@localhost redhat]# ssh -V
OpenSSH_8.9p1, OpenSSL 1.0.2k-fips 26 Jan 2017