Centos升级openSSH9.9p2

0、环境
Centos7.6.1810
OpenSSH_9.1p1, OpenSSL 3.0.14 4 Jun 2024

1、下载源码包

wget https://mirrors.aliyun.com/pub/OpenBSD/OpenSSH/portable/openssh-9.9p2.tar.gz

2、备份旧版本OpenSSH

cp -r /etc/ssh /etc/ssh.20250306.bak
cp /etc/pam.d/sshd.pam /etc/pam.d/sshd.pam.20250306.bak
cp /etc/init.d/sshd /etc/init.d/sshd.20250306.bak
cp -r /usr/bin/openssl /usr/bin/openssl.20250306.bak

3、解压编译

tar -zxvf openssh-9.9p2.tar.gz   # 解压
cd openssh-9.9p2
./configure --prefix=/usr/local/openssh-9.9p2 --sysconfdir=/etc/ssh --with-ssl-dir=/usr/local/openssl-3.0.14 --with-zlib=/usr/local/zlib   # 预编译
make clean && make -j 4 && make install   # 4线程编译安装
/usr/local/openssh-9.9p2/bin/ssh -V   # 查看是否编译成功

4、配置SSH系统启动文件

cp -rf /root/openssh-9.9p2/contrib/redhat/sshd.init /etc/init.d/sshd
cp -rf /root/openssh-9.9p2/contrib/redhat/sshd.pam /etc/pam.d/sshd.pam
cp -rf /root/openssh-9.9p2/sshd_config /etc/ssh/sshd_config
cp -rf /usr/local/openssh-9.9p2/sbin/sshd /usr/sbin/sshd
cp -rf /usr/local/openssh-9.9p2/bin/ssh /usr/bin/ssh
cp -rf /usr/local/openssh-9.9p2/bin/ssh-keygen /usr/bin/ssh-keygen

5、配置服务

chmod u+x /etc/init.d/sshd   # 配置权限
chkconfig --add sshd   # 添加SSH服务到chkconfig
chkconfig --list | grep sshd   # 查看SSH服务
chkconfig sshd on   # 开启SSH开机启动

6、配置SSH参数

echo 'PermitRootLogin yes' >> /etc/ssh/sshd_config   # 允许root远程登陆
echo 'Subsystem sftp /usr/local/ssh/libexec/sftp-server' >> /etc/ssh/sshd_config   # 指向sftp服务

7、重启SSH服务

/etc/init.d/sshd restart   # 重启SSH
/etc/init.d/sshd status   # 查看SSH服务
ssh -V   # 验证是否完成升级
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值