下载新版的ssh源码包
https://openbsd.hk/pub/OpenBSD/OpenSSH/portable/openssh-8.1p1.tar.gz
开启telnet,以防止ssh升级失败无法远程登陆的问题
vi /etc/inetd.conf
将这两行的注释打开,允许telnet服务启动
#telnet stream tcp nowait root /usr/libexec/telnetd telnetd
#telnet stream tcp6 nowait root /usr/libexec/telnetd telnetd
vi /etc/pam.d/login
注释掉这一行
account requisite pam_securetty.so
vi /etc/rc.conf
在文件中新加入一行
inetd_enable="YES" #防止系统重启,telnet关闭
/etc/rc.d/inetd restart #启动telnet
开始升级openssh
tar -xf openssh-8.1p1.tar.gz
cd openssh-8.1p1
/.configure --prefix=/usr/local/openssh-8.1p1
指定安装路径,openssh-8.1p1无需事先创建
make && make install #编译&安装
cd /usr/local/openssh-8.1p1
备份原有的ssh程序
mv /usr/bin/ssh /usr/bin/ssh.old
ln -s ./bin/ssh /usr/bin/ssh #链接新版本程序
mv /usr/sbin/sshd /usr/sbin/sshd.old
ln -s ./sbin/sshd /usr/sbin/sshd
ssh -V #查看新的ssh版本
/usr/local/openssh-8.1p1/sbin/sshd #启动新的ssh程序