一.本機系統:
[root@localhost test]# cat /etc/redhat-release CentOS Linux release 7.5.1804 (Core) [root@localhost test]#
二.安裝gcc
1.你要下載一個CentOS7的系統鏡像(https://www.centos.org/download/) 或者本地有之前的安裝鏡像的話解壓,
解壓出來會有一個Packages 這個文件,
2.在服務器上新建一個gcc文件夾,從Packages中挑選出需要安裝gcc文件,下面8個文件就可以了
3.可以輸入並執行以下命令,查看是否缺少gcc.環境安裝包!
rpm -qa|grep gcc
4.執行gcc 文件夾下執行一下命令
rpm -Uvh *.rpm --nodeps --force
5.此時就安裝成功,可以用 以下命令檢查版本
[root@localhost ~]# gcc -v 使用內建 specs。 COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.8.5/lto-wrapper 目標:x86_64-redhat-linux 配置為:../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-linker-hash-style=gnu --enable-languages=c,c++,objc,obj-c++,java,fortran,ada,go,lto --enable-plugin --enable-initfini-array --disable-libgcj --with-isl=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/isl-install --with-cloog=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/cloog-install --enable-gnu-indirect-function --with-tune=generic --with-arch_32=x86-64 --build=x86_64-redhat-linux 線程模型:posix gcc 版本 4.8.5 20150623 (Red Hat 4.8.5-28) (GCC)
二.. 升級openSSh 到 OpenSSH_8.4p1
1. 下載,需要下載以下三個文件,下載地址如下
https://ftp.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-8.4p1.tar.gz http://www.zlib.net/zlib-1.2.11.tar.gz https://www.openssl.org/source/openssl-1.1.1g.tar.gz
2.解壓升級包
tar -zxvf zlib-1.2.11.tar.gz -C /usr/local tar -zxvf openssh-8.4p1.tar.gz -C /usr/local tar -zxvf openssl-1.1.1g.tar.gz -C /usr/local
3.編譯安裝zlib
cd zlib-1.2.11 ./configure --prefix=/usr/local/zlib make && make install
4.編譯安裝 openssl
cd openssl-1.1.1g ./config --prefix=/usr/local/ssl -d shared make && make install echo '/usr/local/ssl/lib' >> /etc/ld.so.conf ldconfig -v
5. 編譯安裝openssh
cd openssh-8.4p1 ./configure --prefix=/usr/local/openssh --with-zlib=/usr/local/zlib --with-ssl-dir=/usr/local/ssl make && make install
6.sshd_config文件修改
echo 'PermitRootLogin yes' >>/usr/local/openssh/etc/sshd_config echo 'PubkeyAuthentication yes' >>/usr/local/openssh/etc/sshd_config echo 'PasswordAuthentication yes' >>/usr/local/openssh/etc/sshd_config
7. 備份原有文件,並將新的配置復制到指定目錄
mv /etc/ssh/sshd_config /etc/ssh/sshd_config.bak cp /usr/local/openssh/etc/sshd_config /etc/ssh/sshd_config mv /usr/sbin/sshd /usr/sbin/sshd.bak cp /usr/local/openssh/sbin/sshd /usr/sbin/sshd mv /usr/bin/ssh /usr/bin/ssh.bak cp /usr/local/openssh/bin/ssh /usr/bin/ssh mv /usr/bin/ssh-keygen /usr/bin/ssh-keygen.bak cp /usr/local/openssh/bin/ssh-keygen /usr/bin/ssh-keygen mv /etc/ssh/ssh_host_ecdsa_key.pub /etc/ssh/ssh_host_ecdsa_key.pub.bak cp /usr/local/openssh/etc/ssh_host_ecdsa_key.pub /etc/ssh/ssh_host_ecdsa_key.pub
8.啟動sshd
[root@localhost ~]# systemctl daemon-reload [root@localhost ~]# service sshd restart Restarting sshd (via systemctl): [ 確定 ]
9.查看版本ssh版本
[root@localhost ~]# ssh -V OpenSSH_8.4p1, OpenSSL 1.1.1g 21 Apr 2020
10.漏洞修復
這個問題我在網上看到了解決辦法連接如下 https://www.cnblogs.com/fantongxue/p/14604920.html,但是,按照那樣操作之后,ssh 服務重啟,系統重啟, ps -ef| grep scp 發現其進程還在,不知道能不能修復,要是誰有新的解決辦法,還請指教!
11. 今天按照上述的安裝,出現了問題,之前也是這樣子步驟安裝的就可以,問題和解決辦法:
問題:
解決辦法:真是令人頭疼,試了好多辦法,最終:參照如下博主弄好了 https://www.hncldz.com/?p=625
cd openssh-8.6p1 cp -p contrib/redhat/sshd.init /etc/init.d/sshd chmod +x /etc/init.d/sshd chkconfig --add sshd chkconfig sshd on service sshd restart systemctl status sshd
另外:博主中說的 http://blog.chinaunix.net/uid-28813320-id-5786956.html 我按這個辦法試了下,狀態正常了,但是在連接,連接不上了,
所以修改源碼的方法慎用。
補充1.有個別服務器按照上面的方面還是不行,查詢 systemctl status sshd 發現 /usr/lib/systemed/system/sshd.service
原因:
/usr/lib/systemd/system/sshd.service 與systemd不兼容
處理辦法:
mv /usr/lib/systemd/system/sshd.service /etc/ssh_bak/
systemctl daemon-reload
親測,有效,若有不恰當處,還望及時提醒!!!
參考文案:
https://blog.csdn.net/White_Black007/article/details/81357234
https://www.cnblogs.com/tongchengbin/p/13809096.html