# 创建几个目录备用
mkdir -p /usr/local/zlib/ mkdir -p /usr/local/openssl/ mkdir -p /usr/local/openssh/
# 安装编译需要用到的依赖包
yum -y install wget dnf vim gcc gcc-c++ make perl pam-devel
# 下载相关源码包
cd /root wget https://ftp.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-9.3p1.tar.gz --no-check-certificate && wget http://www.zlib.net/zlib-1.2.13.tar.gz && wget https://www.openssl.org/source/openssl-1.1.1t.tar.gz --no-check-certificate
# 解压源码包
tar -zxvf openssl-1.1.1t.tar.gz && tar -zxvf openssh-9.3p1.tar.gz && tar -zxvf zlib-1.2.13.tar.gz
# 卸载openssh
yum remove openssh
# 卸载openssh相关包(不要删除openssl-libs*)
rpm -qa | grep openssl rpm -e --nodeps openssl-1.0.2k-19.el7.x86_64
#进入zlib解压目录
cd /root/zlib-1.2.13
# 预编译
./configure --prefix=/usr/local/zlib/
# 编译安装
make && make install
# 查看版本
ll /usr/local/zlib/lib
#进入openssl解压目录
cd /root/openssl-1.1.1t
# 预编译
./config --prefix=/usr/local/openssl/ --openssldir=/usr/local/openssl/ shared
# 编译安装
make && make install
# 创建软连接文件
ln -s /usr/local/openssl/bin/openssl /usr/bin/openssl echo "/usr/local/openssl/lib" >> /etc/ld.so.conf ldconfig ln -s /usr/local/openssl/lib/libssl.so.1.1 /usr/lib64/libssl.so.1.1 ln -s /usr/local/openssl/lib/libcrypto.so.1.1 /usr/lib64/libcrypto.so.1.1
# 检查版本
openssl version
# 进入openssh解压目录
cd /root/openssh-9.3p1
# 预编译
./configure --prefix=/usr/local/openssh/ --sysconfdir=/etc/ssh/ --with-openssl-includes=/usr/local/openssl/include/ --with-ssl-dir=/usr/local/openssl/ --with-zlib=/usr/local/zlib/ --with-md5-passwords --without-openssl-header-check
# 编译安装
make -j 4 && make install
# 创建软连接文件
ln -s /usr/local/openssh/sbin/sshd /sbin/sshd ln -s /usr/local/openssh/bin/ssh /usr/bin/ssh ln -s /usr/local/openssh/bin/scp /usr/bin/scp ln -s /usr/local/openssh/bin/sftp /usr/bin/sftp ln -s /usr/local/openssh/bin/ssh-add /usr/bin/ssh-add ln -s /usr/local/openssh/bin/ssh-keygen /usr/bin/ssh-keygen ln -s /usr/local/openssh/bin/ssh-keyscan /usr/bin/ssh-keyscan
# 配置启动脚本,并设置开机自启动
cp -rf /root/openssh-9.3p1/contrib/redhat/sshd.init /etc/init.d/sshd cp -rf /root/openssh-9.3p1/contrib/redhat/sshd.pam /etc/pam.d/sshd.pam chkconfig --add sshd chkconfig sshd on
# 修改配置文件
vim /etc/ssh/sshd_config PermitRootLogin yes setenforce 0 vim /etc/selinux/config SELINUX=disabled
# key文件给权限
cd /etc/ssh/ chmod 700 /etc/ssh/*_key
# 检查错误和版本
sshd -T ssh -V
标签:bin,--,openssh,openssl,源码,usr,最新版,local From: https://www.cnblogs.com/jianxiaoxiu/p/17443627.html