centos6,centos7离线升级openssh到最新版本


打包下载:

telnet+vsftp+openssh,centos的离线rpm安装包和依赖包,离线升级openssh教程

tcentos6升级openssh到7.9版本,centos7升级openssh到8.2版本

下载链接


把package上传到家目录

1.安装telnet服务和客户端
    
    1.1按顺序执行
        cd ~/package/telnet
        rpm -Uvh xinetd-2.3.15-13.el7.x86_64.rpm
        rpm -Uvh telnet-server-0.17-64.el7.x86_64.rpm
        rpm -Uvh telnet-0.17-64.el7.x86_64.rpm
    
    1.2启用telnet服务
        ccentos6:
        vi /etc/xinetd.d/telnet
        将其中disable字段的yes改为no以启用telnet服务
        centos7:
        systemctl enable telnet.socket
    
    1.3默认情况下,系统是不允许root用户telnet远程登录的。如果要使用root用户直接登录,需设置如下内容:
        echo  'pts/0'  >>/etc/securetty
        echo 'pts/1' >>/etc/securetty
        
        注释该行
        vi /etc/pam.d/remote
        #auth       required     pam_securetty.so
    
    1.4启动并设置开机自启
        centos6:
        service xinetd start
        chkconfig xinetd on
        centos7:
        systemctl start telnet.socket
    
    1.5测试是否能连接。通过其他linux机器或者Windows cmd窗口,需要安装telnet客户端
        telnet ip
        
        补充:输入用户名密码正确的情况下提示Login incorrect
            修改/etc/pam.d/remote,注释掉:auth  required  pam_securetty.so
            再重启xinetd
        centos6:
        service xinetd restart
        centos7:
        systemctl restart telnet.socket
    
2.安装ftp服务
    2.1.安装vsftp
    
        cd ~/package/vsftp
        rpm -Uvh vsftpd-3.0.2-25.el7.x86_64.rpm
        rpm -Uvh ftp-0.17-67.el7.x86_64.rpm
        
        报错error: Failed dependencies:libcrypto.so.10()(64bit) is needed by vsftpd-2.2.2-24.el6.x86_64
        该服务器上没有安装openssl,先安装openssl-1.0.1e-57.el6.x86_64.rpm,可以先执行步骤3.3安装依赖包
        
    2.2.关闭selinux,先临时关闭,再永久关闭,已经是关闭的就不用管了
    
        临时关闭:
        setenforce 0
    
        永久关闭:
        vi /etc/sysconfig/selinux
        SELINUX=enforcing 改为 SELINUX=disabled
    
    2.3.先备份原有vsftpd.conf
        mv /etc/vsftpd/vsftpd.conf /etc/vsftpd/vsftpd.conf.old
        
        增加和修改配置
        vi /etc/vsftpd/vsftpd.conf
       #centos6,centos7 

       local_root=/home/cent

        #centos7
        allow_writeable_chroot=YES 
        
    2.4.增加ftp账户
        这里设置的账户名为“cent”,密码为“cent”,密码需要输入两遍
        useradd cent -s /sbin/nologin
        passwd cent
        Qwer1234.
        
    2.5.编辑user_list文件,允许cent用户访问FTP
        vi /etc/vsftpd/user_list
        最后一行添加一个用户cent
    
    2.6.开启vsftpd服务并设置开机自启
    centos6:
        service vsftpd start
        chkconfig vsftpd on
    centos7:
        systemctl enable vsftpd
        systemctl start vsftpd
    2.7测试是否能够上传文件
        测试工具有xftp,连接时选择ftp方式,端口号21,用户名和密码都是cent
        ftp工具filezilla
        必须要保证能够上传文件
        文件会上传到local_root=/home/cent

3.升级openssh
        
    3.1断开当前连接的ssh窗口,使用telnet方式连接服务器,需要验证用户名和密码
        telnet ip
        
    3.2停止ssh服务,卸载当前openssh,一定要确保telnet和ftp两个服务跑起来并设置了开机自启以防止服务器突然关机导致连不上机器
        centos6:
        service sshd stop
        rpm -e --nodeps `rpm -qa|grep openssh` 
        centos7:
        systemctl stop sshd
        rpm -e --nodeps `rpm -qa|grep openssh` 
        
        以前的配置文件,安装完后可以恢复它
        warning: /etc/ssh/ssh_config saved as /etc/ssh/ssh_config.rpmsave
        warning: /etc/ssh/sshd_config saved as /etc/ssh/sshd_config.rpmsave
        
    3.3安装依赖包,进入文件夹~/package/openssh/dependencies2
        cd ~/package/openssh/dependencies2
        rpm -Uvh *.rpm --nodeps --force
        
    3.4解压
        进入文件夹
        cd ~/package/openssh
        tar -zxf openssh-8.2p1.tar.gz
        
    3.5编译和安装
        进入解压的目录
        cd openssh-8.2p1
        ./configure --prefix=/usr --sysconfdir=/etc/ssh --with-pam --with-zlib --with-md5-passwords 
        make && make install
        
        centos7:
        报错sshd: no hostkeys available -- exiting.
        有这两文件就chmod,没有就生成,百度查一下
        chmod 600 /etc/ssh/ssh_host_dsa_key
        chmod 600 /etc/ssh/ssh_host_rsa_key
        在执行命令make && make install
        
    3.6复制pam文件,复制启动脚本,设置开机自启
        cp contrib/redhat/sshd.pam /etc/pam.d/sshd
        cp contrib/redhat/sshd.init /etc/init.d/sshd
        
        centos6:
        chkconfig sshd on
        
        centos7:
        systemctl enable sshd
        
    3.7配置ssh_config
        vi /etc/ssh/sshd_config
        PermitRootLogin yes  #允许root用户通过ssh登陆
        PubkeyAuthentication yes #公钥授权
        PasswordAuthentication yes #密码授权
        
    3.8验证版本信息
        ssh -V
        
    3.9启动ssh服务
        centos6:
        service sshd start
        centos7:
        systemctl start sshd
        
    3.10测试ssh服务是否正常
        使用xshell尝试连接服务器
        再重启ssh服务
        service sshd restart
        
        断开连接再重新连接服务器
        
4.关闭telnet
    4.1关闭telnet,关闭开机自启
        centos6:
        service xinetd stop
        chkconfig xinetd off
        
        centos7:
        systemctl stop telnet.socket
        systemctl disable telnet.socket
    4.2删除用户组pts/0和pts/1
        vi /etc/securetty
        最后两个pts/0和pts/1删除
        
    4.3如果修改了/etc/pam.d/remote
        打开注释
        vi /etc/pam.d/remote
        auth       required     pam_securetty.so

5.关闭ftp并删除用户
    5.1打开selinux,如果原来就是关闭的,就不用管它
        setenforce 1
        
        vi /etc/sysconfig/selinux
        SELINUX=disabled 改为 SELINUX=enforcing
        
    5.2关闭ftp服务,禁止开机自启
        centos6:
        service vsftpd stop
        chkconfig vsftpd off
        centos7:
        systemctl stop vsftpd
        systemctl disable vsftpd
        
    5.3删除用户cent和该用户家目录
        userdel -r cent

        
 

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值