Centos7.2升级openssh为9.0p1
[root@localhost bin]# ln -sf /usr/local/ssl/bin/openssl /usr/bin/openssl
[root@localhost bin]# ln -s /usr/local/ssl/include/openssl /usr/include/openssl
1、基础准备
官方网站下载最新版*.tar.gz安装包:
官方下载地址:http://ftp.openbsd.org/pub/OpenBSD/OpenSSH/portable/
openssh-9.0p1.tar.gz (注意:要下载p1版,此版为编译安装包)
官方下载地址:https://www.openssl.org/source/
openssl-1.1.1q.tar.gz
官方下载地址: http://www.zlib.net/
zlib-1.2.12.tar.gz
————————————————
当然这边也全部下载好了,提供百度网盘
链接:https://pan.baidu.com/s/1UoSCLNGQUq7Kuqqga3POhg?pwd=1111
提取码:1111
--来自百度网盘超级会员V8的分享
2、系统环境
ssh -V
可以查看当前版本
3.升级openssh的步骤
3.1解压所有上传的压缩包
tar -zxvf openssh-9.0p1.tar.gz
tar -zxvf openssl-1.1.1q.tar.gz
tar -zxvf zlib-1.2.12.tar.gz
3.2 编译安装zlib
1 2 3 4 5 6 7 8 9 10 | cd zlib-1.2.12 ./configure --prefix=/usr/local/zlib 编译zlib出错,请安装gcc yum install gcc make && make install echo '/usr/local/zlib/lib' >> /etc/ld.so.conf ldconfig -v |
验证zlib安装是否成功,要包含include、lib、share三个目录。
3.3编译安装openssl
1 2 3 4 5 6 7 8 9 | cd openssl-1.1.1q . /config --prefix= /usr/local/ssl -d shared make && make install (时间比较长,切勿打断) echo '/usr/local/ssl/lib' >> /etc/ld .so.conf ldconfig - v <br><br>对之前的openssl进行备份<br>还需要创建一下软连接 |
[root@localhost bin]# mv /usr/bin/openssl /usr/bin/openssl.old
[root@localhost bin]# mv /usr/include/openssl /usr/include/openssl.old
[root@localhost bin]# ln -sf /usr/local/ssl/bin/openssl /usr/bin/openssl
[root@localhost bin]# ln -s /usr/local/ssl/include/openssl /usr/include/openssl
3.4通过Telnet登录到服务器,务必
3.4.1安装telnet(服务端客户端都安装)
yum install -y telnet
yum install -y telnet-server
yum install -y xinetd
3.4.2修改配置文件(默认是没有的,执行)
vim /etc/xinetd.d/telnet
1 2 3 4 5 6 7 8 9 10 | service telnet { flags = REUSE socket_type = stream wait = no user = root server = /usr/sbin/in .telnetd log_on_failure += USERID disable = yes #改为 no 或者注释这一行 } |
3.4.3重启telnet服务
service xinetd restart
3.4.4测试:
[root@localhost pam.d]# telnet localhost
如果无法登陆,解决方法:修改/etc/pam.d/remote,注释掉:auth required pam_securetty.so
3.4.5如果发现端口不通,则排查防火墙,关闭防火墙
systemctl stop firewalld.service
3.5升级安装openssh
3.5.1停止服务并且备份
1 2 3 4 | 停止 ssh 服务 systemctl stop sshd 备份 ssh 配置文件 cp -r /etc/ssh /etc/ssh .old |
查看系统原有openssh包
1 2 3 4 5 6 7 8 | rpm -qa | grep openssh 根据上面查询出的结果,卸载系统里原有Openssh(一般有三个包,全部卸载) rpm -e --nodeps xxxxxxxxxx rpm -e --nodeps openssh-server-7.4p1-21.el7.x86_64 rpm -e --nodeps openssh-7.4p1-21.el7.x86_64 rpm -e --nodeps openssh-clients-7.4p1-21.el7.x86_64 卸载完成后执行rpm -qa | grep openssh,确保没有回显 rpm -qa | grep openssh |
3.5.2安装openssh
cd openssh-9.0p1 ./configure --prefix=/usr/local/openssh --with-zlib=/usr/local/zlib --with-ssl-dir=/usr/local/ssl make && make install #查看目录版本 /usr/local/ssh/bin/ssh -V #复制新ssh文件(由于我这边压缩包都在/root下。不同的请自行更改路径) cp -rf /root/openssh-9.0p1/contrib/redhat/sshd.init /etc/init.d/sshd cp -rf /root/openssh-9.0p1/contrib/redhat/sshd.pam /etc/pam.d/sshd.pam cp -rf /root/openssh-9.0p1/sshd_config /etc/ssh/sshd_config cp -rf /usr/local/openssh/sbin/sshd /usr/sbin/sshd cp -rf /usr/local/openssh/bin/ssh /usr/bin/ssh cp -rf /usr/local/openssh/bin/ssh-keygen /usr/bin/ssh-keygen #开启sshd chmod u+x /etc/init.d/sshd; chkconfig --add sshd ##自启动 chkconfig --list |grep sshd chkconfig sshd on #允许root登录 echo 'PermitRootLogin yes' >>/usr/local/openssh/etc/sshd_config 下面的有可能不需要执行 echo 'PermitRootLogin yes' >> /etc/ssh/sshd_config
#重启sshd服务 /etc/init.d/sshd restart谨慎操作!!!会导致telnet断开 /etc/init.d/sshd status #查看升级后ssh版本 ssh -V
确定没有问题后在关闭telnet服务
#关闭telnet服务
systemctl stop xinetd.service
systemctl stop telnet.socket
#卸载telnet服务
yum remove xinetd telnet-server telnet -y
#防火墙问题比较敏感,生产请谨慎
SSH启动失败问题
1.Permissions 0737 for ‘/etc/ssh/ssh_host_rsa_key’ are too open”问题
1 2 3 4 | chmod 600 /etc/ssh/ssh_host_rsa_key chmod 600 /etc/ssh/ssh_host_dsa_key chmod 600 /etc/ssh/ssh_host_ecdsa_key chmod 600 /etc/ssh/ssh_host_ed25519_key |
如果报OpenSSL升级后导致libcrypt.so.10和libssl.so.10找不到的解决https://blog.csdn.net/yin138/article/details/110820145
提供linux库文件
链接:https://pan.baidu.com/s/19AlKrA8EJCZV_kzZk55SsA?pwd=1111
提取码:1111
有SFTP协议的用户请谨慎升级!ChrootDirectory不起作用!!!!!!
升级完SFTP用户会登录不了或者限制不了根目录
需要重新安装openssh-sever
然后重启下ssh
systemctl restart sshd.service
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步