升级openssh

发布时间 2023-06-14 14:59:15作者: liuxiaobei556

1.安装依赖

yum install pam-devel -y

2.上传压缩包,ssh下载地址

https://cdn.openbsd.org/pub/OpenBSD/OpenSSH/portable/

3.备份配置文件

cp /etc/ssh/sshd_config /home/sshd_config.backup
cp /etc/pam.d/sshd /home/sshd.backup

4.安装OpenSSH

解压openssh

cd openssh/
tar -zxvf openssh-9.0p1.tar.gz
cd openssh-9.0p1

编译配置

./configure --prefix=/usr --sysconfdir=/etc/ssh --with-md5-passwords --with-pam --with-zlib --with-tcp-wrappers --with-ssldir=/usr/local/ssl --without-hardening

编译安装

make && make install

调整文件权限

chmod 600 /etc/ssh/ssh_host_rsa_key
chmod 600 /etc/ssh/ssh_host_ecdsa_key
chmod 600 /etc/ssh/ssh_host_ed25519_key

还原之前的配置文件

mv /home/sshd.backup /etc/pam.d/sshd
mv /home/sshd_config.backup /etc/ssh/sshd_config

修改/etc/ssh/sshd_config配置文件

vim /etc/ssh/sshd_config

UsePAM yes
PermitRootLogin yes
PasswordAuthentication yes
#修改配置文件

重启sshd服务

systemctl restart sshd

查看版本是否升级为9.0p1

ssh -V