ToB企服应用市场:ToB评测及商务社交产业平台

标题: 超具体-内网离线升级openssh7.4p1至9.3p2案例 [打印本页]

作者: 光之使者    时间: 2024-7-21 05:55
标题: 超具体-内网离线升级openssh7.4p1至9.3p2案例
一、操作前预备

 1、确定版本

        查看Linux体系版本
        输入命令:hostnamectl

        查看openssh的版本
        输入命令:ssh -V

2、预备好离线安装包及依赖

openssh-9.3p2.tar.gz、openssl-1.1.1t.tar.gz、zlib-1.2.13.tar.gz、及依赖包:

Gcc依赖包:

Pam_依赖包:

Pam-devel依赖包:

Perl依赖包:


telnet-server依赖包:

Xinetd依赖包:

3、连接ssh服务器

        使用工具连接至ssh服务器,我这里使用的是xshell的工具,全程操作包管root权限下且必须保持一个SSH会话不掉线实行。因此最好是提前安装好telnet。
        3.1tmp目次创建data文件夹

        输入命令:cd /tmp
        输入命令:mkdir data

        上传全部安装包及依赖包到data文件,利用xshell中的xftp上传
        3.2关闭selinux

        查看selinux状态,输入命令:sestatus

        临时关闭selinux,输入命令:setenforce 0
        永世关闭selinux,输入命令:vi /etc/selinux/config  进入编辑模式


输入命令:cd /tmp/data/yilai/telnet-server/

输入命令:rpm -ivh telnet-server-0.17-66.el7.x86_64.rpm

输入命令:cd /tmp/data/yilai/xinetd/
输入命令:rpm -ivh xinetd-2.3.15-14.el7.x86_64.rpm

输入命令:vi /etc/xinetd.d/telnet

写入一下内容:
service telnet
{
    disable = yes
    flags       = REUSE
    socket_type = stream      
    wait        = no
    user        = root
    server      = /usr/sbin/in.telnetd
    log_on_failure  += USERID
}

添加完成后:wq生存退出
输入命令:vi /etc/securetty

增长终端
pts/0
pts/1
pts/2
pts/3

输入命令:systemctl enable xinetd –now
输入命令:systemctl enable telnet.socket –now

输入命令:ss -luntp | grep 23

输入命令:firewall-cmd --zone=public --add-port=23/tcp –permanent

输入命令:firewall-cmd –reload

输入命令:firewall-cmd --zone=public --list-ports

输入命令:telnet ip 23(例:telnet 10.8.202.130 23)回车,输入账号暗码乐成登录

                输入命令:mkdir -p /backup/openssl
        mkdir /backup/openssh

切换到依赖包地点目次,并进入pam-devel文件夹
输入命令:cd /tmp/data/yilai/pam-devel/
实行安装命令:rpm -ivh pam-devel-1.1.8-23.el7.x86_64.rpm

切换到依赖包地点目次,并进入gcc文件夹
输入命令:cd /tmp/data/yilai/gcc /
            实行安装命令:
                  rpm -ivh kernel-headers-3.10.0-1160.92.1.el7.x86_64.rpm
rpm -ivh mpfr-3.1.1-4.el7.x86_64.rpm
rpm -ivh libmpc-1.0.1-3.el7.x86_64.rpm
rpm -ivh glibc-* --replacefiles
rpm -ivh cpp-4.8.5-44.el7.x86_64.rpm
rpm -ivh gcc-4.8.5-44.el7.x86_64.rpm
从上到下依次实行

无报错为安装乐成,有报错处理惩罚报错问题
切换到依赖包地点目次,并进入perl文件夹
输入命令:cd /tmp/data/yilai/perl/
实行安装命令:rpm -ivh *

切换到依赖包地点目次,并进入pam_文件夹
输入命令:cd /tmp/data/yilai/pam_
实行安装命令:
      rpm -ivh boost-*
rpm -ivh boost-serialization-1.53.0-28.el7.x86_64.rpm
rpm -ivh snapper-*
rpm -ivh pcsc-lite-libs-1.8.8-8.el7.x86_64.rpm
rpm -ivh pam_krb5-2.4.8-6.el7.x86_64.rpm
rpm -ivh pam_pkcs11-0.6.2-30.el7.x86_64.rpm
rpm -ivh pam_snapper-0.2.8-4.el7.x86_64.rpm
rpm -ivh pam_ssh_agent_auth-0.10.3-2.22.el7_9.x86_64.rpm
rpm -ivh pam-devel-1.1.8-23.el7.x86_64.rpm
                  从上往下依次安装


无报错安装乐成,否则处理惩罚报错。
输入命令:
     cp /usr/lib64/libcrypto.so.10 /backup/openssl
cp /usr/lib64/libcrypto.so.1.0.2k /backup/openssl
cp /usr/lib64/libssl.so.10 /backup/openssl
cp /usr/lib64/libssl.so.1.0.2k /backup/openssl
输入命令:
mv /usr/bin/openssl /backup/openssl
输入命令:
mv /usr/include/openssl /backup/openssl/include_openssl
输入命令:
cp /etc/ld.so.conf /backup/openssl/etc_ld.so.conf

输入命令: rm -rf /etc/ssl
切换至data目次
输入命令:
cd /tmp/data
tar -xf openssl-1.1.1t.tar.gz
                     切换到openssl-1.1.1t文件夹中
                     输入命令:
                            cd openssl-1.1.1t
                            ./config shared --prefix=/usr/local/ssl

若无报错则继承实行,否则处理惩罚报错问题
输入命令:make && make install
这里需要等一会。等候编译完成后:
输入命令:echo $?   (返回0代表编译安装乐成)

输入命令:
echo "/usr/local/ssl/lib">>/etc/ld.so.conf
ln -s /usr/local/ssl/bin/openssl /usr/bin/openssl
ln -sf /usr/local/ssl/include/openssl /usr/include/openssl
echo "/usr/local/ssl/lib" >/etc/ld.so.conf.d/openssl.conf
ldconfig
从上到下依次实行

输入命令:openssl version

输入命令:
cd /tmp/data
tar -xf zlib-1.2.13.tar.gz
cd zlib-1.2.13/
./configure --prefix=/usr/local/zlib
make && make install (需要等带一段时间)
编译完成输入下面命令,返回0说明乐成
echo $?

输入命令:mv /etc/ssh /backup/openssh
备份pam.d/sshd 文件
输入命令:mv /etc/pam.d/sshd /backup/openssh

输入命令:rpm -qa | grep openssh
输入命令:rpm -e --nodeps `rpm -qa | grep openssh`

输入命令:
      cd /tmp/data/
tar -xzvf openssh-9.3p2.tar.gz
输入命令:cd openssh-9.3p2
输入命令:./configure --prefix=/usr/local/ssh --sysconfdir=/etc/ssh --with-openssl-includes=/usr/local/ssl/include --with-ssl-dir=/usr/local/ssl --with-zlib=/usr/local/zlib --with-md5-passwords --with-pam
输入命令: make && make install
编译完成输入下面命令,返回0说明乐成
echo $?

输入命令:
ln -sf /usr/local/ssh/libexec /usr/libexec/openssh
ln -sf /usr/local/ssh/sbin/sshd /usr/sbin/sshd
ln -sf /usr/local/ssh/bin/scp /usr/bin/scp
ln -sf /usr/local/ssh/bin/ssh /usr/bin/ssh
ln -sf /usr/local/ssh/bin/ssh-add /usr/bin/ssh-add
ln -sf /usr/local/ssh/bin/ssh-agent /usr/bin/ssh-agent
ln -sf /usr/local/ssh/bin/ssh-keygen /usr/bin/ssh-keygen
ln -sf /usr/local/ssh/bin/ssh-keyscan /usr/bin/ssh-keyscan

在openssh的解压文件下实行:
输入命令:
cd /tmp/data/openssh-9.3p2
cp contrib/redhat/sshd.init /etc/init.d/sshd
cp contrib/redhat/sshd.pam /etc/pam.d/sshd.pam
cp contrib/ssh-copy-id /usr/bin/ssh-copy-id
输入命令:chmod 755 /usr/bin/ssh-copy-id

输入命令:
cp /backup/openssh/ssh/sshd_config /etc/ssh/
y
cp /backup/openssh/ssh/ssh_config /etc/ssh/
y
cp /backup/openssh/sshd /etc/pam.d



输入命令:
echo "KexAlgorithms curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha1,diffie-hellman-group-exchange-sha1,diffie-hellman-group1-sha1" >> /etc/ssh/sshd_config

输入命令:vi /etc/ssh/sshd_config
# 取消PubkeyAuthentication yes 的解释
:PubkeyAuthentication yes
# 若UsePAM yes 默认被解释 则关闭解释
UsePAM yes



输入命令:vi /etc/ssh/ssh_config
# 将GSSAPIAuthentication yes解释掉
#GSSAPIAuthentication yes
# 生存并退出

输入命令:
mv /backup/openssl/libcrypto.so.10 /usr/lib64/libcrypto.so.10
y
mv /backup/openssl/libssl.so.10 /usr/lib64/libssl.so.10
y



输入命令:chkconfig sshd on
输入命令:/etc/init.d/sshd start
输入命令:ssh -V




输入命令:
systemctl disable xinetd --now
systemctl disable telnet.socket --now
输入命令:
firewall-cmd --zone=public --remove-port=23/tcp –permanent
输入命令:firewall-cmd –reload
输入命令:firewall-cmd --zone=public --list-ports


免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。




欢迎光临 ToB企服应用市场:ToB评测及商务社交产业平台 (https://dis.qidao123.com/) Powered by Discuz! X3.4