table of Contents
2. Install openssh dependencies
1.openssh download address
https://openbsd.hk/pub/OpenBSD/OpenSSH/portable/openssh-8.0p1.tar.gz
2. Install openssh dependencies
Because the internal network environment cannot connect to the external network, the dependency package required to upgrade openssh cannot be downloaded directly from yum, so first we need to solve the dependency problem required for installation. There are many ways to install dependent packages offline, such as mounting image files for local warehouses, downloading rpm packages from the Internet and then installing them offline.
Here we choose rpm installation. Use the yum command and the --downloadnly parameter in the external network environment to download the dependent package but not install it locally to save it, and then upload it to the internal network using the localinstall command of the yum command to install using the local rpm package, as follows:
# 安装yum-downloadonly,启用--downloadonly
yum -y install yum-downloadonly
# 下载相关依赖包到/opt目录
yum -y install --downloadonly --downloaddir=/opt gcc-c++ openssl-devel pam-devel
# 将所有依赖包转移到内网/opt目录,使用localinstall离线本地安装
yum -y localinstall gcc-c++ openssl-devel pam-devel /opt/*
3. Upgrade openssh8.0
I also put the openssh-8.0p1.tar.gz package under /opt on the intranet. The upgrade process is as follows:
Note : If you are connecting to the server remotely and it is not convenient to operate the server on site, it is recommended to install telnet before the upgrade to prevent the ssh upgrade from failing to connect, otherwise it will be very troublesome.
Do the following to ensure that the previous step is correct and then perform the next step.
# 升级前确认版本
ssh -V
# 进入/opt
cd /opt/
# 解压并进入openssh目录
tar -xvf openssh-8.0p1.tar.gz && cd openssh-8.0p1
# 先备份原来的ssh目录,否则下面编译会出错
mv /etc/ssh /etc/ssh_bak
# 编译安装
./configure --prefix=/usr/ --sysconfdir=/etc/ssh --with-zlib --with-md5-passwords --with-pam && make install
# 检查编译是否异常,0正常否则异常
echo $?
# 备份原有目录
mv /etc/init.d/sshd /etc/init.d/sshd_bak
mv /etc/pam.d/sshd /etc/pam.d/sshd.pam_bak
# 将编译好的文件复制到相关目录下并重命名
cp -a contrib/redhat/sshd.init /etc/init.d/sshd
cp -a contrib/redhat/sshd.pam /etc/pam.d/sshd.pam
# 设置允许root登录,否则将无法登录
echo "PermitRootLogin yes" >> /etc/ssh/sshd_config
# 查看升级后版本
ssh -V
# 重启sshd
service sshd restart
# 打开另一个终端测试连接,当前终端不要退出