• centos7.6升级openssh9.3p1,openssl1.1.1t


    一、安装前查看系统及版本

    1. # cat /etc/redhat-release 
    2. CentOS Linux release 7.2.1511 (Core) 
    3. # ssh -V
    4. OpenSSH_6.6.1p1, OpenSSL 1.0.1e-fips 11 Feb 2013

    二、安装步骤
    1.下载tar包

    1. ​wget https://www.openssl.org/source/openssl-1.1.1t.tar.gz --no-check-certificate
    2. wget https://cdn.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-9.3p1.tar.gz 
    3. wget http://www.zlib.net/zlib-1.2.13.tar.gz

    解压到指定路径:

    1. tar zxvf openssl-1.1.1t.tar.gz -C /usr/local/src/
    2. tar zxvf openssh-9.3p1.tar.gz -C /usr/local/src/
    3. tar zxvf zlib-1.2.13.tar.gz -C /usr/local/src 

    2.安装相关依赖和gcc编译工具

    1. yum -y install gcc gcc-c++ kernel-devel
    2. yum -y install pam pam-devel zlib zlib-devel

    3.安装zlib

    1. cd /usr/local/src/zlib-1.2.13/
    2. ./configure --prefix=/usr/local/zlib && make -j 4 && make install

    4.安装openssl

    1. cd /usr/local/src/openssl-1.1.1t/
    2. ./config --prefix=/usr/local/ssl -d shared
    3. make -j 4 && make install
    4. echo '/usr/local/ssl/lib' >> /etc/ld.so.conf
    5. ldconfig -v

    5.安装openssh

    1. mv /etc/ssh /etc/ssh.bak
    2. cd /usr/local/src/openssh-9.3p1/
    3. ./configure --prefix=/usr/local/openssh --sysconfdir=/etc/ssh --with-ssl-dir=/usr/local/ssl --with-zlib=/usr/local/zlib 
    4. make -j 4 && make install

    6.修改配置文件
    (1)sshd_config文件修改

    1. echo "X11Forwarding yes" >> /etc/ssh/sshd_config
    2. echo "X11UseLocalhost no" >> /etc/ssh/sshd_config
    3. echo "#XAuthLocation /usr/bin/xauth" >> /etc/ssh/sshd_config
    4. echo "UseDNS no" >> /etc/ssh/sshd_config
    5. echo 'PermitRootLogin yes' >> /etc/ssh/sshd_config
    6. echo 'PubkeyAuthentication yes' >> /etc/ssh/sshd_config
    7. echo 'PasswordAuthentication yes' >> /etc/ssh/sshd_config


    需要添加X11Forwarding yes开启X11转发,调用图形界面,如oracle安装等操作需要图形界面
    ***必须添加X11UseLocalhost no 和 XAuthLocation /usr/bin/xauth 这两项,否则X11转发不好使
    验证X11转发是否好使,xhost + 出现下面的是可以正常使用的

    (2) 备份 /etc/ssh 原有文件,并将新的配置复制到指定目录

    1. mv /usr/sbin/sshd /usr/sbin/sshd.bak
    2. cp -rf /usr/local/openssh/sbin/sshd /usr/sbin/sshd
    3. mv /usr/bin/ssh /usr/bin/ssh.bak
    4. cp -rf /usr/local/openssh/bin/ssh /usr/bin/ssh 
    5. mv /usr/bin/ssh-keygen /usr/bin/ssh-keygen.bak
    6. cp -rf /usr/local/openssh/bin/ssh-keygen /usr/bin/ssh-keygen

    安装完成,查看版本ssh -V

    1. # ssh -V
    2. OpenSSH_9.3p1, OpenSSL 1.1.1t  7 Feb 2023

    7.启动sshd

    systemctl restart sshd

    开机自启

    systemctl enable sshd 

    9.天翼云服务器启动sshd问题

    拷贝系统启动文件

    cp /usr/local/src/openssh-9.3p1/contrib/redhat/sshd.init /etc/init.d/sshd

    把原先的systemd管理的sshd文件移走,不然影响重启sshd服务

    1. mv  /usr/lib/systemd/system/sshd.service /usr/lib/systemd/system/sshd.service.bak
    2. systemctl daemon-reload

    将sshd添加到系统服务

    1. chkconfig --add sshd
    2. chkconfig sshd on
    3. # chkconfig --list
    4. Note: This output shows SysV services only and does not include native
    5.       systemd services. SysV configuration data might be overridden by native
    6.       systemd configuration.
    7.       If you want to list systemd services use 'systemctl list-unit-files'.
    8.       To see services enabled on particular target use
    9.       'systemctl list-dependencies [target]'.
    10. denyhosts       0:on    1:on    2:on    3:on    4:on    5:on    6:on
    11. netconsole      0:off   1:off   2:off   3:off   4:off   5:off   6:off
    12. network         0:off   1:off   2:off   3:off   4:off   5:off   6:off
    13. sshd            0:off   1:off   2:on    3:on    4:on    5:on    6:off

    重启sshd

    1. service sshd status
    2. service sshd restart

    10.注意
    注意:升级后由于加密算法的区别,低版本的SSH工具可能无法连接,建议改用Xshell7或SecureCRT9.0以上版本。

  • 相关阅读:
    MAC一体机密码修改或者重新创建账户?
    004 OpenCV akaze特征点检测匹配
    排序算法-归并排序
    openfeign技术学习与总结待续
    为何添加事务管理器呢?spring事务又有哪些传播特性?
    设计模式之美笔记
    SAP中己经用MBST冲销的凭证,可以再次用MBST冲销吗?
    基于webman的CMS,企业官网通用PHP后台管理系统
    把 Maven 提交到项目?Maven Wrapper的使用与好处
    uniapp集成windicss的流程
  • 原文地址:https://blog.csdn.net/LG_15011399296/article/details/133677478