centos 7 升级OpenSSH
openssh-7.9p1版本存在漏洞需要升级到最新的版本。
注意:升级存在风险,导致无法远程登录,最好临时安装Telnet远程服务。
1. 系统版本
[root@test01 ~]# cat /etc/redhat-release CentOS Linux release 7.7.1908 (Core)[root@test01 ~]# openssl versionOpenSSL 1.0.2k-fips 26 Jan 2017[root@test01 ~]# rpm -qa | grep opensshopenssh-7.4p1-11.el7.x86_64openssh-clients-7.4p1-11.el7.x86_64openssh-server-7.4p1-11.el7.x86_642. 安装编辑工具
yum install gcc openssl-devel zlib-devel -y3. 下载openssh最新包
[root@test01 tmp]# wget https://mirrors.sonic.net/pub/OpenBSD/OpenSSH/portable/openssh-8.2p1.tar.gz[root@test01 tmp]# wget https://openbsd.hk/pub/OpenBSD/OpenSSH/portable/openssh-8.2p1.tar.gz4. 备份ssh目录
cp -r /etc/ssh/ /etc/ssh_bak5.解压编辑
tar zxvf openssh-8.2p1.tar.gz cd openssh-8.2p1./configure --prefix=/usr --sysconfdir=/etc/sshmake6.卸载旧版本openssh
rpm -e --nodeps `rpm -qa | grep openssh`rpm -qa | grep opensshmake install报警:
ssh-keygen: generating new host keys: DSA /usr/sbin/sshd -t -f /etc/ssh/sshd_config@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ WARNING: UNPROTECTED PRIVATE KEY FILE! @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@Permissions 0640 for '/etc/ssh/ssh_host_rsa_key' are too open.It is required that your private key files are NOT accessible by others.This private key will be ignored.@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ WARNING: UNPROTECTED PRIVATE KEY FILE! @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@Permissions 0640 for '/etc/ssh/ssh_host_ecdsa_key' are too open.It is required that your private key files are NOT accessible by others.This private key will be ignored.@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ WARNING: UNPROTECTED PRIVATE KEY FILE! @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@Permissions 0640 for '/etc/ssh/ssh_host_ed25519_key' are too open.It is required that your private key files are NOT accessible by others.This private key will be ignored.sshd: no hostkeys available -- exiting.make: [check-config] 错误 1 (忽略)执行:
[root@test01 openssh-8.2p1]# chmod 600 /etc/ssh/ssh_host_rsa_key /etc/ssh/ssh_host_ecdsa_key /etc/ssh/ssh_host_ed25519_key7. 查看版本
[root@test01 openssh-8.2p1]# ssh -VOpenSSH_8.2p1, OpenSSL 1.0.2k-fips 26 Jan 20178.添加服务并允许root登录
[root@test01 openssh-8.2p1]# cp contrib/redhat/sshd.init /etc/init.d/sshd[root@test01 openssh-8.2p1]# chkconfig --add sshd && chkconfig sshd on[root@test01 openssh-8.2p1]# sed -i 's/#PasswordAuthentication yes/PasswordAuthentication yes/g' /etc/ssh/sshd_config[root@test01 openssh-8.2p1]# sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/g' /etc/ssh/sshd_config9. 重启sshd服务--验证远程登录
[root@test01 openssh-8.2p1]# service sshd restart10. 关闭selinux
[root@test01 openssh-8.2p1]# setenforce 0[root@test01 openssh-8.2p1]# sed -i s#SELINUX=enforcing#SELINUX=disabled# /etc/selinux/config
No comments:
Post a Comment