设置窗⼝永不超时,并多开几个ssh窗口,防止有问题
TMOUT=#
备份
cd /etc/ssh/
cp sshd_config sshd_config_bak2024312
解压压缩包
tar -xvzf openssh-9.8p1.tar.gz
检测当前安装包
rpm -qa|grep openssh
openssh-clients-7.4p1-21.el7.x86_64
openssh-server-7.4p1-21.el7.x86_64
openssh-7.4p1-21.el7.x86_64
升级openssh
yum localinstall openssh-*.rpm -y
检测是否升级成功
rpm -qa|grep openssh
openssh-clients-9.8p1-3.el7.x86_64
openssh-debuginfo-9.8p1-3.el7.x86_64
openssh-9.8p1-3.el7.x86_64
openssh-server-9.8p1-3.el7.x86_64
查看版本ssh -V
OpenSSH_9.8p1, OpenSSL 3.0.14 4 Jun 2024
将更新之后配置⽂件备份
cd /etc/ssh
mv sshd_config sshd_config_new_2024312
将备份的配置⽂件替换回去
cp sshd_config_bak2024312 sshd_config
处理⽂件权限
chmod 600 /etc/ssh/ssh_host_rsa_key
chmod 600 /etc/ssh/ssh_host_ecdsa_key
chmod 600 /etc/ssh/ssh_host_ed25519_key
检查配置⽂件下⾯两项
sed -i 's#UsePAM yes#UsePAM no#g' /etc/ssh/sshd_config
cat /etc/ssh/sshd_config |grep UsePAM (显示 UsePAM no 就说明成功了)
修改以下配置文件,更改登录权限
vi /etc/ssh/sshd_config
PermitRootLogin yes
PasswordAuthentication yes
ChallengeResponseAuthentication no
UsePAM yes # 配置为 yes
X11Forwarding yes
UseDNS no
GSSAPIAuthentication no
重启ssh服务
systemctl restart sshd
systemctl enable sshd
查看ssh端⼝,测试远程连接,注意:不要断开当前窗⼝,新开窗⼝测试
netstat -ntlp|grep sshd
openssh-9.8p1.tar.gz(20.42MB)
推荐阅读