centos7升级 openssl1.1.1k和OpenSSH_8.6p1

友情提醒:由于openssh的更新可能会影响到ssh的登录所以保险起见最好先配置talnet的登录,万一openssh更新失败页不至于ssh不能正常登录

1.查看服务器当前版本
ssh -V
image.png
2.到官网下载最新版本openssl和openssh
image.png
3.先更新openssl
4.先更新所需的依赖包
yum install -y gcc gcc-c++ glibc make autoconf openssl openssl-devel pcre-devel pam-devel
yum install -y pam zlib

5.解压新版本openssl
tar -zxvf *.tar.gz

6.手动编译
./config --prefix=/usr/local/openssl
make
make install

7.

备份旧的openssl文件

mv /usr/bin/openssl /usr/bin/openssl.old
mv /usr/lib64/openssl /usr/lib64/openssl.old
mv /usr/lib64/libssl.so /usr/lib64/libssl.so.old
#创建软链接
ln -s /usr/local/openssl/bin/openssl /usr/bin/openssl
ln -s /usr/local/openssl/include/openssl /usr/include/openssl
ln -s /usr/local/openssl/lib/libssl.so /usr/lib64/libssl.so
echo "/usr/local/openssl/lib" >> /etc/ld.so.conf
ldconfig -v #显示正在扫描的目录及搜索到的动态链接库

8.测试
openssl version
image.png

9.解压新版本openssh
tar -zxvf **.tar.gz

10.重新授权,其实不授权页不会影响安装
chown -R root.root /usr/local/data/openssh-8.6p1

11.备份
mv /etc/ssh /etc/sshbak
mv /usr/bin/ssh /usr/bin/sshbak
mv /usr/sbin/sshd /usr/sbin/sshdbak

删除掉以前的ssh
rm -rf /etc/ssh/*

12.切换到新版本openssh根目录
./configure --prefix=/usr/ --sysconfdir=/etc/ssh --with-openssl-includes=/usr/local/openssl/include --with-ssl-dir=/usr/local/openssl --with-zlib --with-md5-passwords --with-pam && make && make install

13.修改sshd_config配置文件
vim /etc/ssh/sshd_config

PermitRootLogin prohibit-password

修改成 PermitRootLogin yes

PasswordAuthentication yes 注释去掉

UseDNS no

修改成UseDNS no

14.验证配置
grep "^PermitRootLogin" /etc/ssh/sshd_config
grep "UseDNS" /etc/ssh/sshd_config

15.回到新版本openssh拷贝文件
cp -a contrib/redhat/sshd.init /etc/init.d/sshd
cp -a contrib/redhat/sshd.pam /etc/pam.d/sshd.pam
chmod +x /etc/init.d/sshd

16.添加sshd开机启动
chkconfig --add sshd
systemctl enable sshd

17.把原先的sshd文件移走或者删除 否则影响新版本的启动
mv /usr/lib/systemd/system/sshd.service /

  1. 设置sshd服务开机启动
    chkconfig sshd on

19.测试启停服务
/etc/init.d/sshd restart
netstat -lntp
/etc/init.d/sshd stop
netstat -lntp

使用systemctl方式也行
systemctl stop sshd
netstat -lntp

systemctl start sshd
netstat -lntp

20.查看版本
ssh -V

image.png

至此openssl和openssh 更新到此完成

你可能感兴趣的:(centos7升级 openssl1.1.1k和OpenSSH_8.6p1)