OpenSSH升级
上传软件包openssh-8.1p1.tar.gz
1.安装telnet服务
yum -y install telnet-server* telnet (yum install -y xinetd )
vi /etc/xinetd.d/telnet (将其中disable字段的yes改为no以启用telnet服务)
mv /etc/securetty /etc/securetty.old #允许root用户通过telnet登录
service xinetd start #启动telnet服务 (&& systemctl start telnet.socket && systemctl enable telnet.socket)
chkconfig xinetd on #使telnet服务开机启动,避免升级过程中服务器意外重启后无法远程登录
2.备份路径
mkdir /etc/sshbak
mv /etc/ssh/* /etc/sshbak #备份原来的ssh配置文件
mv /etc/init.d/sshd /etc/init.d/sshdbak #备份原来的ssh启用脚本
3.安装基础依赖包
yum install -y gcc openssl-devel pam-devel rpm-build
4.解压openssh-8.1p1.tar.gz
#tar -zxvf openssh-8.1p1.tar.gz
进入解压目录
cd openssh-8.1p1
配置openssh
./configure --prefix=/usr/ --sysconfdir=/etc/ssh --with-ssl-dir=/usr/local/openssl
编译安装
make && make install
5.复制启动脚本到/etc/init.d
cp -a contrib/redhat/sshd.init /etc/init.d/sshd
6.查看/etc/ssh目录下是否存在配置文件
#ll /etc/ssh
moduli sshd_config ssh_host_dsa_key.pub ssh_host_ecdsa_key.pub ssh_host_ed25519_key.pub ssh_host_rsa_key.pub
ssh_config ssh_host_dsa_key ssh_host_ecdsa_key ssh_host_ed25519_key ssh_host_rsa_key
7.开启允许root管理员登录
修改配置文件:
vi /etc/ssh/sshd_config
找到#PermitRootLogin prohibit-password
在下面一行添加PermitRootLogin yes
PermitRootLogin yes
8.重启sshd服务
service sshd restart
9.查看ssh版本(确保版本为升级的版本)
# ssh -V
OpenSSH_8.1p1, OpenSSL 1.0.1e-fips 11 Feb 2013
10.验证openssh没问题后关闭telnet服务
mv /etc/securetty.old /etc/securetty
chkconfig xinetd off
service xinetd stop