centos7.x默认的ssh版本都是7.x的,但是比如我们做等宝2.0等要求对服务器进行安全扫描的时候,会要求我们升级到8.X版本。显然跨版本后。我们直接使用yum update是无法进行升级的。这就需要我们手动升级。升级方式如下。
第一步官网下载openssh8.2和openssl1.1,升级ssh对应的ssl也要升级。懒得去官网找的,文章最后已经打包好,自行下载即可。
第一步、编译安装ssl
传统安装方式,直接解压压缩包,切到openssl中按照下面命令执行即可。
./config --prefix=/usr/local/openssl
make && make install
替换旧的SSL
mv /usr/bin/openssl /usr/bin/openssl.old
mv /usr/lib64/openssl /usr/lib64/openssl.old
mv /usr/lib64/libssl.so /usr/lib64/libssl.so.old
ln -s /usr/local/openssl/bin/openssl /usr/bin/openssl
ln -s /usr/local/openssl/include/openssl /usr/include/openssl
ln -s /usr/local/openssl/lib/libssl.so /usr/lib64/libssl.so
echo “/usr/local/openssl/lib” >> /etc/ld.so.conf
ldconfig -v
第二步、安装SSH
删除ssh
rm -rf /etc/ssh/*
安装
./configure --prefix=/usr/ --sysconfdir=/etc/ssh --with-openssl-includes=/usr/local/openssl/include --with-ssl-dir=/usr/local/openssl --with-zlib --with-md5-passwords --with-pam && make && make install
修改配置文件(这个其实就是设置允许root登录但是后面不知道为啥没好用-最终处理完了以后在vi /etc/ssh/sshd_config加参数也可以)
grep “^PermitRootLogin” /etc/ssh/sshd_config
grep “UseDNS” /etc/ssh/sshd_config
可能下面的ssh.pam文件都没用到,因为sshd_config配置文件貌似没使用它,请自行测试。我这边是拷贝了
cp -a contrib/redhat/sshd.init /etc/init.d/sshd
cp -a contrib/redhat/sshd.pam /etc/pam.d/sshd.pam
chmod +x /etc/init.d/sshd
chkconfig --add sshd
systemctl enable sshd
把原先的systemd管理的sshd文件删除或者移走或者删除,不移走的话影响我们重启sshd服务
mv /usr/lib/systemd/system/sshd.service /data/
设置sshd服务开机启动
chkconfig sshd on
最后修改允许root登录
vi /etc/ssh/sshd_config
增加该参数
PermitRootLogin yes
接下来测试重启服务
/etc/init.d/sshd restart
PS:最后做一个说明,有些童鞋的SSH工具太老了。服务器升级新的SSH协议后,加密方式有变动,可以老的SSH客户端工具不支持,有遇到的建议升级下客户端工具。或则用win10的powershell试一下。
最后奉上打包好的下载链接----如果近期内看到这个文章的可以直接下载,还是建议自己去官网下载最新的。
https://download.csdn.net/download/Himly_Zhang/12926565