Ubuntu 16 更新openssh 8.8

最近项目所在服务器由于ssh协议版本过低,有风险所以更新ssh协议到8.8,特此记录(linux 菜鸡很多东西理解不到位,还望海涵)

1. 查阅资料后,主要有几个注意点地方

1.1 yum 更新国内源

1.2 更新ssh之前先安装telnet,因为是远程ssh连接,所以在ssh更新安装失败时,应该有备用连接方案

1.3 生产机器更新有风险,一定要做好备份

2. 安装流程

2.1 更新apt 国内阿里源

先备份原来的源,在进行更新
cd  /etc/apt/
cp sources.list ./sources.list.back
>sources.list
vi souces.list

写入

deb https://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse
deb https://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiverse
deb https://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted universe multiverse
deb https://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse

更新一下

apt-get update

2.2下载安装包

我的安装包路径 /home/openssh/

wget https://www.openssl.org/source/openssl-1.1.1m.tar.gz
wget https://fastly.cdn.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-8.8p1.tar.gz
wget http://www.zlib.net/zlib-1.2.11.tar.gz

下载下来解压

2.3 安装telnet

netstat -a | grep telnet
输出空,则没有安装telnet

1. 安装telnet

apt-get install openbsd-inetd

apt-get install  telnetd telnet

apt-get install xinetd

#注意安装顺序有不一致的话,需要检查openbsh-inted配置文件,/etc/inetd.conf
telnet  stream  tcp  nowait  telnetd /usr/sbin/tcpd  /usr/sbin/in.telnetd

2. 查看状态
service xinetd status

3. (注意如果/etc/inetd.conf 有那条记录可以不重启)启动服务
/etc/init.d/openbsd-inetd restart 

5. 查看telnet 运行端口
netstat -anpt|grep 23

6. 测试是否可以登录(在别的机器上登录)
telnet ip

2.4 安装 zlib

1.
cd zlib-1.2.11


2.
#最好执行前更新一下gcc
apt-get install build-essential

3. 注意prefix的路径ssh要用到,需要记住
./configure --preifx={url}
./configure --prefix=/usr/local/zlib/

4.
make

5.make install

6. 备份老版openssl(可能老版本的文件不存在,掠过)
mv /usr/bin/openssl /usr/bin/openssl.old
mv /usr/include/openssl /usr/include/openssl.old
mv /usr/local/openssl /usr/local/openssl.old

2.5 安装openssl

1.注意prefix的路径ssh要用到,需要记住
./config shared --prefix=/usr/local/ssl

2.
make test

3.
make install

4. 建立软连接备份
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

2.6 安装openssh

#停止sshd 22的端口监听服务
service sshd stop

清除ssh配置
apt purge ssh

#进入校验安装
./configure --prefix=/usr/local/openssh --with-zlib=/usr/local/zlib --with-ssl-dir=/usr/local/ssl

make
make install

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/openssh/sbin/sshd /usr/bin/sshd

2.7安装完毕后连接ssl和sshd文件

sshd
mv /usr/sbin/sshd /usr/sbin/sshd.bk
ln -s /usr/local/openssh/sbin/sshd /usr/sbin/

ssl
ln -s /usr/local/ssl/bin/openssl /usr/bin/openssl
ln -s /usr/local/ssl/include/openssl /usr/include/openssl

2.8重启ssh(应该在验证版本正确之后重启)

重启风险,一定要能在telnet登录这台机器的情况下重启
service sshd restart

加载配置
service sshd reload 

2.9 验证安装(验证版本)

退出当前登录,然后重新ssh登录

ssh -V
sshd -V
openssl version -a

在这里插入图片描述
最后应该还差添加开机启动,懒得弄所以就以后再说吧

参考了这位老哥的文章:https://blog.csdn.net/qq_40907977/article/details/106076934

  • 14
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值