centos7.9升级openssh
source link: https://blog.51cto.com/liuxiaogd/5753806
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
centos7.9升级openssh
精选 原创liuxiaogd 2022-10-13 16:43:25 ©著作权
文章标签 centos7.9 openssh 文章分类 Linux 系统/运维 阅读数193
第一步:关闭防火墙
[root@localhost ~]# systemctl stop firewalld
第二步:查看系统版本 点击查看代码
[root@localhost ~]# cat /etc/redhat-release
[root@localhost ~]# rpm -qa | grep openssh
[root@localhost ~]# ssh -V
第三步:准备环境,安装编译所需依赖软件包
[root@localhost ~]# yum -y install wget tar gcc make
第四步:下载软件
[root@localhost ~]# wget --no-check-certificate https://nchc.dl.sourceforge.net/project/libpng/zlib/1.2.11/zlib-1.2.11.tar.gz
[root@localhost ~]# wget --no-check-certificate https://www.openssl.org/source/openssl-1.1.1d.tar.gz
[root@localhost ~]# wget --no-check-certificate https://mirrors.sonic.net/pub/OpenBSD/OpenSSH/portable/openssh-9.0p1.tar.gz或者
Wget --no-check-certificate https://mirrors.aliyun.com/pub/OpenBSD/OpenSSH/portable/openssh-9.0p1.tar.gz
[root@localhost ~]# tar -xzvf zlib-1.2.11.tar.gz
[root@localhost ~]# tar -xzvf openssl-1.1.1d.tar.gz
[root@localhost ~]# tar -xzvf openssh-9.0p1.tar.gz
第五步、安装libz
[root@localhost ~]# cd zlib-1.2.11
[root@localhost zlib-1.2.11]# ./configure --prefix=/usr/local/zlib
[root@localhost zlib-1.2.11]# make && make install
[root@localhost zlib-1.2.11]# cd
第六步、安装openssl
[root@localhost ~]# cd openssl-1.1.1d
[root@localhost openssl-1.1.1d]# ./config --prefix=/usr/local/ssl -d shared
[root@localhost openssl-1.1.1d]# make && make install
[root@localhost openssl-1.1.1d]# echo '/usr/local/ssl/lib' >> /etc/ld.so.conf
[root@localhost openssl-1.1.1d]# ldconfig -v
[root@localhost openssl-1.1.1d]# cd
第七步、安装openssh-9.0p1
[root@localhost ~]# cd openssh-9.0p1
[root@localhost openssh-9.0p1]# ./configure --prefix=/usr/local/openssh --with-zlib=/usr/local/zlib --with-ssl-dir=/usr/local/ssl
[root@localhost openssh-9.0p1]# make && make install
第八步、删除低版本OpenSSH的的rpm包
[root@localhost openssh-9.0p1]# rpm -e --nodeps `rpm -qa | grep openssh`
第九步、修改配置
启动前要将新生成的sshd_config修改以下几个地方
[root@localhost ~]# vim /usr/local/openssh/etc/sshd_config
按i,把下面复制进去,按esc ,输入:wq!保存
PermitRootLogin yes
PubkeyAuthentication yes
PasswordAuthentication yes
复制文件到相应的系统文件夹
[root@localhost ~]# cd openssh-9.0p1
[root@localhost openssh-9.0p1]# cd contrib/redhat/
[root@ localhost redhat]# cp sshd.init /etc/init.d/sshd
[root@ localhost redhat]# chkconfig --add sshd
[root@ localhost redhat]# cp /usr/local/openssh/etc/sshd_config /etc/ssh/sshd_config
[root@ localhost redhat]# cp /usr/local/openssh/sbin/sshd /usr/sbin/sshd
[root@ localhost redhat]# cp /usr/local/openssh/bin/ssh /usr/bin/ssh
[root@ localhost redhat]# cp /usr/local/openssh/bin/ssh-keygen /usr/bin/ssh-keygen
[root@ localhost redhat]# cp /usr/local/openssh/etc/ssh_host_ecdsa_key.pub /etc/ssh/ssh_host_ecdsa_key.pub
是否覆盖“y”
[root@ localhost redhat]#
[root@localhost ~]#cd zlib-1.2.11
[root@localhost zlib-1.2.11]#./configure --prefix=/usr/local/zlib
[root@localhost zlib-1.2.11]#make && make install
[root@localhost zlib-1.2.11]#cd
第六步、安装openssl
[root@localhost ~]#cd openssl-1.1.1d
[root@localhost openssl-1.1.1d]#./config --prefix=/usr/local/ssl -d shared
[root@localhost openssl-1.1.1d]#make && make install
[root@localhost openssl-1.1.1d]#echo '/usr/local/ssl/lib' >> /etc/ld.so.conf
[root@localhost openssl-1.1.1d]#ldconfig -v
[root@localhost openssl-1.1.1d]#cd
第七步、安装openssh-9.0p1
[root@localhost ~]#cd openssh-9.0p1
[root@localhost openssh-9.0p1]#./configure --prefix=/usr/local/openssh --with-zlib=/usr/local/zlib --with-ssl-dir=/usr/local/ssl
[root@localhost openssh-9.0p1]#make && make install
第八步、删除低版本OpenSSH的的rpm包
[root@localhost openssh-9.0p1]#rpm -e --nodeps `rpm -qa | grep openssh`
第九步、修改配置
启动前要将新生成的sshd_config修改以下几个地方
[root@localhost ~]#vim /usr/local/openssh/etc/sshd_config
PermitRootLogin yes
PubkeyAuthentication yes
PasswordAuthentication yes
复制文件到相应的系统文件夹
[root@localhost ~]#cd openssh-9.0p1
[root@localhost openssh-9.0p1]#cd contrib/redhat
[root@ localhost openssh-9.0p1]# cd /usr/local/src/openssh-9.0p1/contrib/redhat
[root@ localhost redhat]# cp sshd.init /etc/init.d/sshd
[root@ localhost redhat]# chkconfig --add sshd
[root@ localhost redhat]# cp /usr/local/openssh/etc/sshd_config /etc/ssh/sshd_config
[root@ localhost redhat]# cp /usr/local/openssh/sbin/sshd /usr/sbin/sshd
[root@ localhost redhat]# cp /usr/local/openssh/bin/ssh /usr/bin/ssh
[root@ localhost redhat]# cp /usr/local/openssh/bin/ssh-keygen /usr/bin/ssh-keygen
[root@ localhost redhat]# cp /usr/local/openssh/etc/ssh_host_ecdsa_key.pub /etc/ssh/ssh_host_ecdsa_key.pub
[root@ localhost redhat]#
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK