Linux ssh升级

1.yum方式升级

升级的版本最高为7.4

yum update -y openssh
2.安装包升级

可升级到最新版本

  • 下载openssh、openssl
wget --no-check-certificate  https://www.openssl.org/source/openssl-1.1.1q.tar.gz
wget --no-check-certificate  https://mirrors.sonic.net/pub/OpenBSD/OpenSSH/portable/openssh-9.8p1.tar.gz
  • 解压备份
tar -zxvf openssh-9.8p1.tar.gz
tar -zxvf openssl-1.1.1q.tar.gz
cp -r /etc/ssh /etc/ssh-bak
  • 编译安装ssl
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

在这里插入图片描述

  • 编译安装ssh
cd ../openssh-9.8p1/
./configure --prefix=/usr/local/openssh --with-zlib=/usr/local/zlib --with-ssl-dir=/usr/local/ssl
make && make install
  • 修改sshd_config
vim /usr/local/openssh/etc/sshd_config

在这里插入图片描述

  • ssh启动文件与配置替换
cp  ./contrib/redhat/sshd.init /etc/init.d/sshd
chkconfig --add sshd
cp /usr/local/openssh/etc/sshd_config /etc/ssh/sshd_config
cp /usr/local/openssh/sbin/sshd /usr/sbin/sshd
cp /usr/local/openssh/bin/ssh /usr/bin/ssh
cp /usr/local/openssh/bin/ssh-keygen /usr/bin/ssh-keygen
cp /usr/local/openssh/etc/ssh_host_ecdsa_key.pub /etc/ssh/ssh_host_ecdsa_key.pub
  • ssh重启与版本查看
service sshd restart
systemctl restart sshd.service
systemctl enable sshd.service
ssh -V

在这里插入图片描述

Logo

更多推荐