当前位置:   article > 正文

升级OpenSSH 9.8p1(CentOS 7)_openssh9.8p1升级

openssh9.8p1升级

升级OpenSSH 9.8p1(CentOS 7)

下载地址

安装gcc

获取所需的 RPM 包

  • gcc
  • gcc-c++
  • cpp
  • glibc-devel
  • libmpc
  • mpfr
  • zlib-devel
  • binutils
  • pam
  • pam-devel

可以在上面提供的阿里云镜像rpm源中找到

批量安装

rpm  -ivh  *.rpm --nodeps --force
  • 1

安装Perl

检查是否已安装Perl,已经安装可以选择跳过

# 解压
tar -zxvf perl-x.xx.x.tar.gz

# 进入解压后的目录中
cd perl-x.xx.x/

# 配置、安装Perl
./Configure -des -Dprefix=/usr/local/perl
#编译
make
#安装
make install
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12

配置环境变量

# 配置环境变量
vim ~/.bash_profile

#这里的/usr/local/perl是上面配置的安装目录,如果配置了别的安装目录可以自行修改
# 在文件最末尾增加一行
export PATH=/usr/local/perl/bin:$PATH

# 刷新缓存
source ~/.bash_profile

# 检查是否安装成功
perl -V
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12

安装zlib

检查是否已安装zlib,已经安装可以选择跳过

# 解压文件,注意替换版本
tar -zxvf zlib.tar.gz
cd zlib-x.x.x

#配置安装目录,有需要的可以自行更改
./configure --prefix=/usr/local/zlib

#编译
make

#安装
make install
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12

编制环境变量

# 配置环境变量
vim ~/.bash_profile

#这里的/usr/local/perl是上面配置的安装目录,如果配置了别的安装目录可以自行修改
# 在文件最末尾增加一行
export LD_LIBRARY_PATH=/usr/local/zlib/lib:$LD_LIBRARY_PATH

# 刷新缓存
source ~/.bash_profile

# 输出include、lib、share文件夹,就算安装完成
ls /usr/local/zlib
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12

安装OpenSSL

卸载原来的OpenSSL

# 会输出例如:openssl-1.0.2k-8.el7.x86_64
rpm -qa | grep openssl | grep -v lib

# openssl-1.0.2k-8.el7.x86_64 为上面命令的输出
yum -y remove openssl-1.0.2k-8.el7.x86_64
  • 1
  • 2
  • 3
  • 4
  • 5

安装

# 解压,注意替换版本号
tar -zxvf openssl-x.x.x.tar.gz

# 进入解压后的目录
cd openssl-x.x.x

# 注意这个目录,高版本可能是/usr/local/openssl/lib64,低版本/usr/local/openssl/lib
./config --prefix=/usr/local/openssl --openssldir=/usr/local/openssl -Wl,-rpath,/usr/local/openssl/lib64 shared

make && make install
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10

注意!注意!注意!

注意:安装检查一下/usr/local/openssl目录下是lib还是lib64,如果与你./config配置的不符合,请重新配置安装执行./config 将你当前版本的lib或者lib64目录,然后再执行make && make install,一定要配置对,不然后面配置安装Open SSH执行./configure时候会报错找不到SSL的头文件

创建软链接

ln -s /usr/local/openssl/bin/openssl /usr/bin/openssl
ln -s /usr/local/openssl/include/openssl /usr/include/openssl
  • 1
  • 2

更新系统配置

注意!注意!注意!

注意:/usr/local/openssl/lib64这个目录要看你安装后的/usr/local/openssl/目录下是lib还是lib64,一定要配置对!

echo "/usr/local/openssl/lib64" >> /etc/ld.so.conf
/sbin/ldconfig
  • 1
  • 2

检查版本

openssl version
  • 1

安装OpenSSH

卸载原来的版本

rpm -qa | grep openssh
# 输出
openssh-clients-7.4p1-11.el7.x86_64
openssh-7.4p1-11.el7.x86_64
openssh-server-7.4p1-11.el7.x86_64

# 注意替换版本号
yum -y remove openssh-clients-7.4p1-11.el7.x86_64 openssh-7.4p1-11.el7.x86_64 openssh-server-7.4p1-11.el7.x86_64
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8

备份Open SSH配置文件

cp -r /etc/ssh /etc/ssh.bak
rm -rf /etc/ssh
  • 1
  • 2

安装

tar -zxvf openssh-portable-V_9_8_P1.tar.gz
cd openssh-portable-V_9_8_P1

# 配置
./configure --prefix=/usr/local/openssh --sysconfdir=/etc/ssh --with-openssl-includes=/usr/local/openssl/include  --with-ssl-dir=/usr/local/openssl  --with-zlib  --with-md5-passwords  --with-pam  --with-ssl-engine

make && make install
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7

创建软链接

ln -s /usr/local/openssh/sbin/sshd /usr/sbin/sshd
ln -s /usr/local/openssh/bin/ssh /usr/bin/ssh
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
  • 1
  • 2
  • 3
  • 4
  • 5

将openssh的服务脚本复制到/etc/init.d目录下

# 备注:sshd.init 文件是存放在openssh的压缩包中,需要在解压的文件夹中查找
cp /home/szym/open_ssh_files/openssh-portable-V_9_8_P1/contrib/redhat/sshd.init /etc/init.d/sshd
chmod u+x /etc/init.d/sshd
  • 1
  • 2
  • 3

添加sshd服务

chkconfig --add sshd
  • 1

检查openssh版本

systemctl restart sshd
ssh -V
  • 1
  • 2

升级完新的ssh配置文件默认关闭root账户的远程登录,如需开启请修改配置文件/etc/ssh/sshd_config

# 找到配置项 PermitRootLogin 改为 yes
PermitRootLogin yes
  • 1
  • 2

参考

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/正经夜光杯/article/detail/976431?site
推荐阅读
相关标签
  

闽ICP备14008679号