一.本机系统:

 cent os 7.9 离线安装gcc 升级openssh openssh-8.4p1_ssh升级

 

 

二.准备好依赖包

  1.gcc

cent os 7.9 离线安装gcc 升级openssh openssh-8.4p1_Linux_02

 

 2.openssh 

cent os 7.9 离线安装gcc 升级openssh openssh-8.4p1_Linux_03

 三. 在服务器上新建文件夹上传依赖包

 四.安装

1)  gcc

进入gcc 文件夹下执行命令

rpm -Uvh *.rpm --nodeps --force

 验证是否安装成功

gcc -v

2)升级openSSh 到 openSSh_8.4p1

       ①解压升级包

    tar -zxvf zlib-1.2.11.tar.gz -C /usr/local

    tar -zxvf openssh-8.4p1.tar.gz -C /usr/local

    tar -zxvf openssl-1.1.1g.tar.gz -C /usr/local

  ②编译安装zlib

 

    cd zlib-1.2.11

 

    ./configure --prefix=/usr/local/zlib

 

    make && make install

 

    编译安装 openssl

 

    cd openssl-1.1.1g

 

    ./config --prefix=/usr/local/ssl -d shared  

 

    make && make install

 

    echo '/usr/local/ssl/lib' >> /etc/ld.so.conf

 

    ldconfig -v

 

   编译安装openssh

 

    cd openssh-8.4p1

 

    ./configure --prefix=/usr/local/openssh --with-zlib=/usr/local/zlib --with-ssl-dir=/usr/local/ssl

 

    make && make install

 

  sshd_config文件修改

 

    echo'PermitRootLogin yes' >>/usr/local/openssh/etc/sshd_config

 

    echo 'PubkeyAuthentication yes' >>/usr/local/openssh/etc/sshd_config

 

    echo 'PasswordAuthentication yes' >>/usr/local/openssh/etc/sshd_config

  备份原有文件,并将新的配置复制到指定目录

 

    mv /etc/ssh/sshd_config /etc/ssh/sshd_config.bak

 

    cp /usr/local/openssh/etc/sshd_config /etc/ssh/sshd_config

 

    mv /usr/sbin/sshd /usr/sbin/sshd.bak

 

    cp /usr/local/openssh/sbin/sshd /usr/sbin/sshd

 

    mv /usr/bin/ssh /usr/bin/ssh.bak

 

    cp /usr/local/openssh/bin/ssh /usr/bin/ssh

 

    mv /usr/bin/ssh-keygen /usr/bin/ssh-keygen.bak

 

    cp /usr/local/openssh/bin/ssh-keygen /usr/bin/ssh-keygen

 

    mv /etc/ssh/ssh_host_ecdsa_key.pub /etc/ssh/ssh_host_ecdsa_key.pub.bak

 

    cp /usr/local/openssh/etc/ssh_host_ecdsa_key.pub /etc/ssh/ssh_host_ecdsa_key.pub

 

五.启动

    systemctl daemon-reload

 

    service sshd restart

 

  查看版本ssh版本

 

    ssh -V

 

六.问题

 重启ssh服务出错

 

mkdir /etc/ssh_bak/

 

mv /usr/lib/systemd/system/sshd.service /etc/ssh_bak/ 

 

systemctl daemon-reload

 

systemctl restart sshd

 

systemctl status sshd