CentOS 7 下升级OpenSSH 7.4p1到OpenSSH 8.4p1
文章目录
一、环境介绍
`openssh版本`
[root@localhost ~]# openssl version
OpenSSL 1.0.2k-fips 26 Jan 2017
[root@localhost ~]# ssh -V
OpenSSH_7.4p1, OpenSSL 1.0.2k-fips 26 Jan 2017
`linux发行版和内核`
[root@localhost ~]# cat /etc/os-release
NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:7"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"
CENTOS_MANTISBT_PROJECT="CentOS-7"
CENTOS_MANTISBT_PROJECT_VERSION="7"
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION="7"
[root@localhost ~]# uname -r
3.10.0-957.el7.x86_64
二、安装配置telnet
2.1、安装telnet-server
[root@localhost ~]# yum -y install xinetd telnet-server
2.2、配置telnet
`先看一下xinetd.d目录下是否有telnet文件`
[root@localhost ~]# ll /etc/xinetd.d/telnet
ls: cannot access /etc/xinetd.d/telnet: No such file or directory
`如果有,则将文件里面的disable = no改成disable = yes`
`如果没有,就进行下面的操作`
[root@localhost ~]# cat > /etc/xinetd.d/telnet <<EOF
service telnet
{
disable = yes
flags = REUSE
socket_type = stream
wait = no
user = root
server = /usr/sbin/in.telnetd
log_on_failure += USERID
}
EOF
2.3、配置telnet登录的终端类型
[root@localhost ~]# cat >> /etc/securetty <<EOF
pts/0
pts/1
pts/2
pts/3
EOF
2.4、启动telnet服务
[root@localhost ~]# systemctl enable xinetd --now
[root@localhost ~]# systemctl enable telnet.socket --now
[root@localhost ~]# ss -nltp | grep 23
LISTEN 0 128 :::23 :::* users:(("systemd",pid=1,fd=46))
`23端口起来了,表示telnet服务正常运行`
三、切换登录方式为telnet
- 后面的操作都是在telnet链接的方式下进行,避免ssh中断导致升级失败
- 以telnet方式登录的时候,注意选择协议和端口,协议为telnet,端口为23
四、开始升级OpenSSH
4.1、下载升级所需依赖包
[root@localhost ~]# yum -y install gcc gcc-c++ glibc make autoconf openssl openssl-devel pcre-devel pam-devel
4.2、下载OpenSSL和OpenSSH
- openssl官网:https://www.openssl.org/
- openssh官网:http://www.openssh.com/
[root@localhost ~]# wget https://www.openssl.org/source/openssl-1.1.1i.tar.gz
[root@localhost ~]# wget http://ftp.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-8.4p1.tar.gz
[root@localhost ~]# tar xf openssl-1.1.1i.tar.gz
[root@localhost ~]# tar xf openssh-8.4p1.tar.gz
4.3、编译安装OpenSSL
`开始之前,先备份一下原有的OpenSSL文件`
[root@localhost ~]# mv /usr/bin/openssl{,.bak}
[root@localhost ~]# mv /usr/include/openssl{,.bak}
[root@localhost ~]# cd openssl-1.1.1i/
[root@localhost openssl-1.1.1i]# ./config shared && make && make install
`编译完成后,可以在/usr/local目录下找到openssl的二进制文件和目录`
[root@localhost ~]# ll /usr/local/bin/openssl
-rwxr-xr-x 1 root root 749136 Jan 14 14:25 /usr/local/bin/openssl
[root@localhost ~]# ll -d /usr/local/include/openssl/
drwxr-xr-x 2 root root 4096 Jan 14 14:25 /usr/local/include/openssl/
`建立软连接`
[root@localhost ~]# ln -s /usr/local/bin/openssl /usr/bin/openssl
[root@localhost ~]# ln -s /usr/local/include/openssl/ /usr/include/openssl
[root@localhost ~]# ll /usr/bin/openssl
lrwxrwxrwx 1 root root 22 Jan 14 14:32 /usr/bin/openssl -> /usr/local/bin/openssl
[root@localhost ~]# ll -d /usr/include/openssl
lrwxrwxrwx 1 root root 27 Jan 14 14:33 /usr/include/openssl -> /usr/local/include/openssl/
`重新加载配置,验证openssl版本`
[root@localhost ~]# echo "/usr/local/lib64" >> /etc/ld.so.conf
[root@localhost ~]# /sbin/ldconfig
[root@localhost ~]# openssl version
OpenSSL 1.1.1i 8 Dec 2020
4.3.1、可能会有的一些报错和解决方法
[root@localhost ~]# openssl version
openssl: error while loading shared libraries: libssl.so.1.1: cannot open shared object file: No such file or directory
"这是因为libssl.so.1.1文件找不到,执行find / -name 'libssl.so.1.1',将/etc/ld.so.conf里面的lib64改成find出来的路径即可"
[root@localhost ~]# find / -name "openssl"
"编译完,可以用上面的find命令看一下openssl所在的路径,以及include/openssl所在的路径"
4.4、编译安装OpenSSH
`备份原有的ssh目录`
[root@localhost ~]# mv /etc/ssh{,.bak}
[root@localhost ~]# mkdir /usr/local/openssh
[root@localhost ~]# cd openssh-8.4p1/
[root@localhost openssh-8.4p1]# ./configure --prefix=/usr/local/openssh \
--sysconfdir=/etc/ssh \
--with-openssl-includes=/usr/local/include \
--with-ssl-dir=/usr/local/lib64 \
--with-zlib \
--with-md5-passwords \
--with-pam && \
make && \
make install
4.4.1、配置sshd_config文件
[root@localhost ~]# echo "UseDNS no" >> /etc/ssh/sshd_config
[root@localhost ~]# echo 'PermitRootLogin yes' >> /etc/ssh/sshd_config
[root@localhost ~]# echo 'PubkeyAuthentication yes' >> /etc/ssh/sshd_config
[root@localhost ~]# echo 'PasswordAuthentication yes' >> /etc/ssh/sshd_config
`如果是图形化界面,需要x11的话,需要配置如下`
[root@localhost ~]# echo "X11Forwarding yes" >> /etc/ssh/sshd_config
[root@localhost ~]# echo "X11UseLocalhost no" >> /etc/ssh/sshd_config
[root@localhost ~]# echo "XAuthLocation /usr/bin/xauth" >> /etc/ssh/sshd_config
4.4.2、创建新的sshd二进制文件
[root@localhost ~]# mv /usr/sbin/sshd{,.bak}
[root@localhost ~]# mv /usr/bin/ssh{,.bak}
[root@localhost ~]# mv /usr/bin/ssh-keygen{,.bak}
[root@localhost ~]# ln -s /usr/local/openssh/bin/ssh /usr/bin/ssh
[root@localhost ~]# ln -s /usr/local/openssh/bin/ssh-keygen /usr/bin/ssh-keygen
[root@localhost ~]# ln -s /usr/local/openssh/sbin/sshd /usr/sbin/sshd
`查看openssh当前版本`
[root@localhost ~]# ssh -V
OpenSSH_8.4p1, OpenSSL 1.1.1i 8 Dec 2020
4.4.3、重新启动openssh服务
[root@localhost ~]# systemctl disable sshd --now
[root@localhost ~]# mv /usr/lib/systemd/system/sshd.service{,.bak}
[root@localhost ~]# systemctl daemon-reload
[root@localhost ~]# cp -a openssh-8.4p1/contrib/redhat/sshd.init /etc/init.d/sshd
[root@localhost ~]# cp -a openssh-8.4p1/contrib/redhat/sshd.pam /etc/pam.d/sshd.pam
[root@localhost ~]# chkconfig --add sshd
[root@localhost ~]# systemctl enable sshd --now
4.5、ssh链接成功后的处理
[root@localhost ~]# ssh root@192.168.145.130
`成功连接上之后,可以关闭telnet服务,当然,也可以不关闭`
[root@localhost ~]# systemctl disable xinetd.service --now
[root@localhost ~]# systemctl disable telnet.socket --now
CentOS 7 下升级OpenSSH 7.4p1到OpenSSH 8.4p1的更多相关文章
- CentOS 7下升级MySQL5.7.23的一个坑
发现CentOS 7下升级MySQL5.7.23的一个坑,以前面升级到MySQL 5.7.23的一个集群为例 在我们环境下打开文件描述符个数的参数open_files_limit在MySQL 5.6. ...
- CentOS 6 下升级安装Mysql 5.5 完整步骤
使用系统CentOS 6.2本来已经系统自带安装了mysql 5.1,但是奈何5.1不支持utf8mb4字符集(详见:http://blog.csdn.net/shootyou/article/det ...
- 在centos 7下升级内核
前言 今天读了一篇老外的文章,讲的是如何在linux环境下升级内核.比较暴力,比较简单,故做个记录. 文章中,作者先列出一个常识:linux是内核名,不是系统名.我们平时说的"lin ...
- CentOS 7下升级Python版本到3.x系列
由于python官方已宣布2.x系列即将停止支持,为了向前看,我们升级系统的python版本为3.x系列服务器系统为当前最新的CentOS 7.4 1.安装前查看当前系统下的python版本号 # p ...
- linux centos系统下升级python版本
本文参考资料:https://www.cnblogs.com/leon-zyl/p/8422699.html,https://blog.csdn.net/tpc1990519/article/deta ...
- CentOS 7下升级python版本到3.X
由于python官方已宣布2.x系列即将停止支持,为了向前看,我们升级系统的python版本为3.x系列服务器系统为当前最新的CentOS 7.4 1.安装前查看当前系统下的python版本号 # p ...
- CentOS 6下升级Python版本
CentOS6.8默认的python版本是2.6,而现在好多python组件开始只支持2.7以上的版本,比如说我今天遇到的pip install pysqlite,升级python版本是一个痛苦但又常 ...
- Centos/Linux 下升级python2.7至3.5.0
(一) 安装Python3.5 (1)在安装python之前,因为linux系统下默认没有安装wget,gcc,首先安装wget,gcc: [root@node6 python_scripts]# y ...
- centos 7 下升级自带 sqlite3
问题 在 centos 7 上面运行 django 2.2 开发服务器时出现: django.core.exceptions.ImproperlyConfigured: SQLite 3.8.3 or ...
随机推荐
- Zuul的应用
一.介绍 注:Zuul中默认就已经集成了Ribbon负载均衡和Hystix熔断机制.但是所有的超时策略都是走的默认值,比如熔断超时时间只有1S,很容易就触发了. 二.依赖 <dependency ...
- CSS命名规范整理
基于网易NEC修改后,整理的命名规范 单行写完一个选择器定义 便于选择器的寻找和阅读,也便于插入新选择器和编辑,便于模块等的识别.去除多余空格,使代码紧凑减少换行. 如果有嵌套定义,可以采取内部单行的 ...
- 【爬虫】将 Scrapy 部署到 k8s
一. 概述 因为学习了 docker 和 k8s ,不管什么项目都想使用容器化部署,一个最主要的原因是,使用容器化部署是真的方便.上一篇文章 [爬虫]从零开始使用 Scrapy 介绍了如何使用 scr ...
- Java 异常分析
Java 异常分析 本文是对以下内容的分析: Java异常设计 Java 异常分类 Java异常可以告诉什么问题 Java异常处理最佳实践 Java Exception 是为了处理应用程序的异常行为而 ...
- docker镜像制作及发布
以centos为例. 主要内容:安装docker,制作镜像,发布镜像. 安装docker 1. 安装docker yum install -y docker 等待一会,安装成功,查看安装列表 2. 启 ...
- Go环境配置和GoModule
Linux相关 Linux常用操作 mkdir directory --创建文件夹 vi file --创建文件,再关闭vim rm file --删除文件 rm -rf directory --递归 ...
- C# 类的继承问题 正方形周长面积计算问题
1. 设计编写一个控制台应用程序,练习类的继承. (1) 编写一个抽象类 People,具有"姓名","年龄"字段,"姓名"属性,Work ...
- 【采坑小计】thanos receiver的官方文档中,并未说明tsdb落盘的配置方式
官方文档的地址在:https://thanos.io/tip/components/receive.md/ 一开始以为落盘的时间间隔是:--tsdb.retention=15d 实际测试中发现,tha ...
- 【记录一个问题】opencv中 cv::dft()与cv::ocl_dft()计算的结果相差较大
以一个跟踪算法来测试: 使用cv::dft(), 矩阵未按照2次幂对齐,最终跟踪平均准确率 84.3% 使用cv::dft(),矩阵使用cv::copyMakeBorder对齐,最终跟踪平均准确率 8 ...
- Windows和Linux关闭占用端口
关闭端口的方式有很多种,但是常用的就是这种比较来的快一点 如果通过以下方式解决不了,可以通过关闭服务来解决 Windows 1.查看端口占用的进程 netstat -ano | findstr 800 ...