正统 OpenSSH 升级 简单说明
基本信息
此轻量版升级不包含 FIPS 模块和对 PAM 的支持
需肥胖版请跳至附录 A
安装依赖包
基于 RedHat 6.10 Minimal 编写
[ @~ ]# yum install gcc zlib-devel
上传升级源码包至服务器至 root 用户家目录 ( 默认 /root/ )
创建安装目录
[ @~ ]# mkdir -p /opt/openssl
[ @~ ]# mkdir -p /opt/openssh
解压文件
[ @~ ]# ls openss*.tar.gz | xargs -n1 tar xzvf
安装 OpenSSL 至 /opt/openssl
[ @~ ]# cd openssl*
[ @openssl* ]# ./config --prefix=/opt/openssl
[ @openssl* ]# make
[ @openssl* ]# make install
[ @openssl* ]# cd
[ @~ ]# echo '/opt/openssl/lib/' >> /etc/ld.so.conf.d/openssl.so.conf
[ @~ ]# ldconfig
[ @~ ]# /opt/openssl/bin/openssl version
安装 OpenSSH 至 /opt/openssh
[ @~ ]# cd openssh*
[ @openssh* ]# ./configure --prefix=/opt/openssh --with-ssl-dir=/opt/openssl
[ @openssh* ]# make
[ @openssh* ]# make install
[ @openssh* ]# cd
[ @~ ]# /opt/openssh/bin/ssh -V
至此,新 OpenSSL 与 OpenSSH 安装工作已完成,接下来是移除旧的 openssh-server 与 openssh-clients 程序,系统原有关于 OpenSSL 的包不做任何更改
卸载原有 openssh 相关程序
[ @~ ]# yum remove openssh openssh-server openssh-clients
添加环境变量
[ @~ ]# echo 'export PATH=$PATH:/opt/openssh/bin' >> /etc/profile.d/ssh.sh
[ @~ ]# source /etc/profile
简单配置 sshd
[ @~ ]# echo 'PermitRootLogin yes' >> /opt/openssh/etc/sshd_config
此时可以发起新的 ssh 连接到此服务器,但若此前已 ssh 连接过服务器,那么还需要删除客户端用户 ~/.ssh/known_hosts 中关于此服务器的公钥
修改并添加 SysV 服务管理脚本
以下两种操作二选一
[ @~ ]# ln -s /opt/openssh/sbin/sshd /usr/sbin/sshd
[ @~ ]# sed '42,46d' ./openssh*/contrib/redhat/sshd.init > /etc/init.d/sshd
[ @~ ]# service sshd start
[ @~ ]# chkconfig sshd on
[ @~ ]# echo '/opt/openssh/sbin/sshd' >> /etc/rc.d/rc.local
[ @~ ]# chmod +x /etc/rc.d/rc.local
[ @~ ]# source /etc/rc.local
至此,轻量版 OpenSSH 升级工作已完成
附录 A: 相关功能一键升级
有需求,再添加
Aug 21, 2020

浙公网安备 33010602011771号