openssh-8.8 安装最新版

1、安装依赖包

apt install libzip-dev libssl-dev autoconf gcc libxml2 make -y

2、下载源码文件包

wget "https://cdn.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-8.8p1.tar.gz"
wget https://www.openssl.org/source/openssl-1.1.1l.tar.gz --no-check-certificate
wget http://www.zlib.net/zlib-1.2.11.tar.gz
tar -xvf openssh-8.8p1.tar.gz
tar -xvf openssl-1.1.1l.tar.gz
tar -xvf zlib-1.2.11.tar.gz

3、编译安装zlib

cd zlib-1.2.11
./configure --prefix=/usr/local/zlib
make
make install

4、编译安装openssl

cd ..
apt purge openssl
cd openssl-1.1.1l
./config shared --prefix=/usr/local/ssl
make
make install
ln -s /usr/local/ssl/lib/libssl.so.1.1 /usr/lib/libssl.so.1.1
ln -s /usr/local/ssl/lib/libcrypto.so.1.1 /usr/lib/libcrypto.so.1.1

mv /usr/bin/openssl /usr/bin/openssl.bak
mv /usr/include/openssl /usr/include/openssl.bak
ln -s /usr/local/ssl/bin/openssl /usr/bin/openssl
ln -s /usr/local/ssl/include/openssl /usr/include/openssl
echo "/usr/local/ssl/lib" >> /etc/ld.so.conf
ldconfig –v
openssl version

5、编译安装openssh

cd ..
service sshd stop
apt purge ssh
cd openssh-8.8p1
./configure --prefix=/usr/local/openssh --with-zlib=/usr/local/zlib --with-ssl-dir=/usr/local/ssl
make 
make install
mv /usr/sbin/sshd /usr/sbin/sshd.old.bk
cp sshd /usr/sbin/
cp sshd /etc/init.d/sshd
cp ssh /etc/init.d/ssh
cp sshd /usr/local/sbin/sshd
cp ssh /usr/local/sbin/ssh

6、设置相关配置文件

mv /usr/bin/scp /tmp/
mv /usr/bin/ssh* /tmp/
ln -s /usr/local/openssh/bin/ssh /usr/bin/ssh
ln -s /usr/local/openssh/bin/scp /usr/bin/scp
ln -s /usr/local/openssh/bin/ssh-add /usr/bin/ssh-add
ln -s /usr/local/openssh/bin/ssh-agent /usr/bin/ssh-agent
ln -s /usr/local/openssh/bin/ssh-keygen  /usr/bin/ssh-keygen
ln -s /usr/local/openssh/bin/ssh-keyscan /usr/bin/ssh-keyscan
ln -s /usr/local/sbin/sshd /usr/bin/sshd

7、重启ssh服务

ssh  -V
sshd -V
openssl version –a

8、开机自启动

chmod +x /etc/init.d/sshd
sysv-rc-conf sshd
sysv-rc-conf sshd on
sysv-rc-conf --list sshd
service  sshd  restart 

注意:service sshd restart 实际上是用不了的,原因未知(尴尬),有知道的可以评论告诉我一下,但是能查到版本号,就已经安装成功了,执行完开机自启动代码,开机也是能启动的,风险评级也是能通过的。

你可能感兴趣的:(Linux,ssh,linux,centos)