Centos7.9升级openssh9.0

本文档详细介绍了如何从源代码编译并安装OpenSSH服务的过程,包括备份配置文件、准备开发环境、下载源码包、解压及配置安装步骤、设置systemctl管理、配置允许root用户登录等关键环节。
1.备份
cp -rp /etc/ssh /etc/ssh.bak
2.准备
yum install -y openssl openssl-devel gcc gcc-c++ make zlib-devel
rpm -e   --nodeps `rpm -qa | grep openssh`
3.下载openssh包
cd /root
wget https://mirrors.aliyun.com/openssh/openssh-9.0.tar.gz?spm=a2c6h.25603864.0.0.27b368eexAJ1UM
4.解压安装
tar -zxvf openssh-9.0p1.tar.gz -C ./
cd openssh-9.0p1/
./configure --prefix=/usr/ --sysconfdir=/etc/ssh/ --with-ssl-dir=/usr/local/ssl --with-md5-passwords --mandir=/usr/share/man/
make && make install
6.配置systemctl管理
cat >/usr/lib/systemd/system/sshd.service<<EOF
[Unit]
Description=OpenSSH server daemon
Documentation=man:sshd(8) man:sshd_config(5)
After=network.target
[Service]
ExecStart=/usr/sbin/sshd
[Install]
WantedBy=multi-user.target
EOF
7.解决报错与允许root用户登录

在这里插入图片描述

sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin  yes/g' /etc/ssh/sshd_config
chmod 600 /etc/ssh/ssh_host_rsa_key /etc/ssh/ssh_host_ecdsa_key /etc/ssh/ssh_host_ed25519_key
8.启动
systemctl enable sshd
systemctl start sshd
9.检查
# 查看openssh版本,可能需要重新开启终端
ssh -V
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值