升級至openssl 1.1.1版本node
升級至openssh 8.0版本vim
openssl version -a 當前查看版本安全
一.安裝telnet (以防升級失敗,連不上服務器,建議弄)服務器
#查看是否安裝ssh
rpm -qa | grep telnet socket
rpm -qa | grep xinetd 函數
#若無安裝,yum安裝測試
yum -y install telnet* 3d
yum -y install xinetd rest
#將服務開機自啓(此處根據自身狀況考慮)
systemctl enable xinetd.service
systemctl enable telnet.socket
#開啓服務
systemctl start telnet.socket
systemctl start xinetd
vi /etc/securetty
在最後添加兩行
pts/0
pts/1
systemctl restart xinetd
netstat -plnt |grep 23確認下
2、升級OpenSSl
一、查看源版本
[root@zj ~]# openssl version -a
二、解壓安裝
tar zxvf openssl-1.1.1c.tar.gzcd openssl-1.0.1g
cd openssl-1.1.1c
./config --prefix=/usr/local/openssl #檢查環境
./config –t
make #編譯
make install #編譯安裝
cd /usr/local
ldd /usr/local/openssl/bin/openssl #檢查函數庫
echo "/usr/local/openssl/lib" >> /etc/ld.so.conf #添加所缺函數庫
ldconfig -v #更新函數庫
openssl/bin/openssl version #查看新安裝的版本
which openssl #查看舊版本openssl命令在哪裏
mv /bin/openssl /usr/bin/openssl.old #將舊版本openssl移除
ln -s /usr/local/openssl/bin/openssl /usr/bin/openssl #新版本製做軟連接
openssl version 最後查看版本,更新完畢
在確保Openssl版本爲1.0.1後,能夠升級Openssh了,升級方法以下。
解壓,進入編譯
備份舊版本
mv /etc/ssh /etc/ssh.old
cd openssh-8.0p1/
./configure --prefix=/usr/local/openssh --sysconfdir=/etc/ssh --with-pam --with-ssl-dir=/usr/local/openssl --with-md5-passwords --mandir=/usr/share/man --with-zlib=/usr/local/zlib --without-hardening
在安裝的過程當中如遇到如下錯誤,請安裝yum -y install openssl-devel
如遇如下錯誤,請安裝yum -y install pam-devel
configure: error: PAM headers not found
我升級的時候只遇到這兩個錯,如遇到別的錯,請自行解決。
而後make && make install
修改啓動腳本
cp ./contrib/redhat/sshd.init /etc/init.d/sshd 拷貝啓動腳本
修改啓動腳本
vim /etc/init.d/sshd
按以下圖修改
SSHD=/usr/local/openssh/sbin/sshd
/usr/local/openssh/bin/ssh-keygen –A
/sbin/restorecon /etc/ssh/ssh_host_key.pub
/sbin/restorecon /etc/ssh/ssh_host_rsa_key.pub
/sbin/restorecon /etc/ssh/ssh_host_dsa_key.pub
/sbin/restorecon /etc/ssh/ssh_host_ecdsa_key.pub
修改sshd配置文件/etc/ssh/sshd_config
echo "PermitRootLogin yes" >> /etc/ssh/sshd_config #直接用root登陸終端(此處根據自身狀況考慮)
echo 'X11Forwarding yes' >> /etc/ssh/sshd_config #設置是否容許X11轉發
echo "PasswordAuthentication yes" >> /etc/ssh/sshd_config #是否容許密碼驗證
卸載原有ssh(先安裝後卸載,也是怕升級失敗,若是有把我,可先卸載)
for i in $(rpm -qa |grep openssh);do rpm -e $i --nodeps ;done
提示警告:
將警告中修改的名字改回來
mv /etc/ssh/sshd_config.rpmsave /etc/ssh/sshd_config
mv /etc/ssh/ssh_config.rpmsave /etc/ssh/ssh_config
mv /etc/ssh/moduli.rpmsave /etc/ssh/moduli
cp -arp /usr/local/openssh/bin/* /usr/bin/ 替換相關命令
service sshd restart 重啓sshd服務
驗證升級、讓其餘人測試鏈接後再退出
ssh -V 和telnet
開機自啓
chkconfig --add sshd
chkconfig --level 2345 sshd on
chkconfig --list
升級完成後,爲了安全起見,建議關閉telnet
#關閉服務(此處根據自身狀況考慮)
systemctl stop telnet.socket
systemctl stop xinetd
#關閉服務開機自啓(此處根據自身狀況考慮)
systemctl disable xinetd.service
systemctl disable telnet.socket