天天看点

OpenSSH升级版本到最新(8.4)

1、依赖软件包:

yum install wget gcc -y
yum install -y zlib-devel openssl-devel 
yum install pam-devel libselinux-devel zlib-devel openssl-devel -y       

2、下载安装包OpenSSH8.4上传至服务器或wget直接下载

wget https://cdn.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-8.4p1.tar.gz      

3、删除低版本OpenSSH的的rpm包

rpm -e --nodeps `rpm -qa | grep openssh`      

4、安装openssh

(1).解压

tar -zxvf openssh-8.4p1.tar.gz
cd  openssh-8.4p1      

(2).配置

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

(3).编译安装

make
make install      

(4)赋权

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

(5)复制配置文件并设置允许root用户远程登录

cp -a contrib/redhat/sshd.init  /etc/init.d/sshd
cp -a contrib/redhat/sshd.pam /etc/pam.d/sshd.pam
chmod u+x /etc/init.d/sshd
vim /etc/ssh/sshd_config      

1.修改#PermitRootLogin prohibit-password项,去掉注释#并把prohibit-password改为yes,修改后即为PermitRootLogin yes

2.去掉注释#PasswordAuthentication yes变为PasswordAuthentication yes

(6)添加添加自启服务ssh到开机启动项

chkconfig --add sshd
chkconfig sshd on      

(7)重启服务

systemctl restart sshd      

(8)查看下安装结果:

ssh -V      

继续阅读