ubuntu18升级openssh

下载安装包

wget http://www.zlib.net/zlib-1.2.13.tar.gz
wget http://www.cpan.org/src/5.0/perl-5.16.1.tar.gz
wget https://github.com/linux-pam/linux-pam/releases/download/v1.3.1/Linux-PAM-1.3.1.tar.xz
wget https://www.openssl.org/source/openssl-1.1.1q.tar.gz
wget http://ftp.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-8.8p1.tar.gz

安装必要的编译环境(可选)

sudo apt-get install build-essential

升级或安装Zlib

tar -xzvf zlib-1.2.13.tar.gz
cd zlib-1.2.13
./configure --prefix=/usr/local/zlib
make
sudo make install

安装或升级 Perl

tar -xzf perl-5.16.1.tar.gz
cd perl-5.16.1
./Configure -de
make
sudo make install
perl -v  #查看版本

安装pam-devel

tar -xf Linux-PAM-1.3.1.tar.xz
cd Linux-PAM-1.3.1
./configure
make
sudo make install

安装或升级 OpenSSL

tar -zxvf openssl-1.1.1q.tar.gz
cd openssl-1.1.1q
./config --prefix=/usr/local --openssldir=/usr/local/openssl shared
make
sudo make install
sudo sh -c "echo '/usr/local/ssl/lib' >> /etc/ld.so.conf"
sudo ldconfig -v
openssl version  #查看版本

安装或升级 OpenSSH

tar -zxvf openssh-8.8p1.tar.gz
cd openssh-8.8p1
sudo ./configure --prefix=/usr/local/openssh --with-zlib=/usr/local/zlib
sudo make clean
sudo make
sudo make install

配置sshd_config文件

sudo sh -c "echo 'PermitRootLogin yes' >>/usr/local/openssh/etc/sshd_config"
sudo sh -c "echo 'PubkeyAuthentication yes' >>/usr/local/openssh/etc/sshd_config"
sudo sh -c "echo 'PasswordAuthentication yes' >>/usr/local/openssh/etc/sshd_config"

备份原来sshd相应配置文件并复制新文件到指定目录

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

验证是否升级成功

ssh -V

重启sshd服务

sudo /etc/init.d/ssh restart
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值