当前位置:   article > 正文

Centos 7 升级openssh_centos7升级openssh

centos7升级openssh
  1. #!/bin/bash
  2. # 安装编译环境
  3. yum install -y gcc gcc-c++ glibc make autoconf openssl openssl-devel pcre-devel pam* zlib*
  4. # 【openssl】
  5. # 备份当前openssl
  6. mv /usr/bin/openssl /usr/bin/openssl_bak
  7. mv /usr/include/openssl /usr/include/openssl_bak
  8. # 编译安装openssl
  9. tar xf openssl-1.1.1o.tar.gz
  10. cd openssl-1.1.1o
  11. ./config shared && make && make install
  12. cp libssl.so.1.1 /usr/lib64/
  13. cp libcrypto.so.1.1 /usr/lib64/
  14. ln -s /usr/local/include/openssl /usr/include/openssl
  15. echo "/usr/local/lib64" >> /etc/ld.so.conf
  16. /sbin/ldconfig
  17. openssl version
  18. # 创建软连接 openssl-1.1.1o 这个版本
  19. ln -s /usr/local/bin/openssl /usr/bin/openssl
  20. ln -s /usr/local/include/openssl /usr/include/openssl
  21. # 【openssh】
  22. # 编译安装
  23. https://mirrors.aliyun.com/pub/OpenBSD/OpenSSH/portable/openssh-9.5p1.tar.gz
  24. tar xf openssh-9.5p1.tar.gz
  25. cd openssh-9.5p1
  26. # 隐藏版本号
  27. sed -i 's/OpenSSH_9.0/OpenSSH_899/g' version.h
  28. wget "http://hello.ejoydom.com:19009/static/openssh-9.3p1.tar.gz"
  29. ./configure --prefix=/usr/local/myssh_9.5p1 --sysconfdir=/usr/local/myssh_9.5p1/ssh --with-openssl-includes=/usr/include/openssl --with-ssl-dir=/usr/local/lib64 --with-privsep-user=sshd --with-zlib --with-pam
  30. make && make install
  31. # 备份openssh
  32. mv /etc/init.d/sshd /etc/init.d/sshd1124.bak
  33. mv /usr/sbin/sshd /usr/sbin/sshd1124.bak
  34. mv /etc/ssh/sshd_config /etc/ssh/sshd_config1124.bak
  35. mv /usr/bin/ssh /usr/bin/ssh1124.bak
  36. # 创建软连接
  37. cp contrib/redhat/sshd.init /etc/init.d/sshd
  38. ln -s /usr/local/myssh_9.5p1/sbin/sshd /usr/sbin/sshd
  39. ln -s /usr/local/myssh_9.5p1/ssh/sshd_config /etc/ssh/sshd_config
  40. ln -s /usr/local/myssh_9.5p1/bin/ssh /usr/bin/ssh
  41. # 复制sshd启动脚本
  42. # 允许root用户远程连接
  43. #sed -i '20a PermitRootLogin yes' /usr/local/myssh_9.3p1/ssh/sshd_config
  44. # 避开绿盟安全扫描
  45. echo "Protocol 2" >> /usr/local/myssh_9.3p1/ssh/sshd_config
  46. echo "Banner /etc/ssh_banner" >> /usr/local/myssh_9.3p1/ssh/sshd_config
  47. # 禁止dns解析
  48. sed -i 's/#UseDNS no/UseDNS no/g' /usr/local/myssh_9.3p1/ssh/sshd_config
  49. # 不移走的话影响启动
  50. mv /usr/lib/systemd/system/sshd.service /root/
  51. chkconfig sshd on
  52. # 重启sshd (默认不许root登录 )
  53. systemctl restart sshd

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/花生_TL007/article/detail/285736
推荐阅读
相关标签
  

闽ICP备14008679号