# CentOS升级OpenSSH版本

参考文档:

# 网络相关

  1. Centos安装telnet服务

    sudo yum -y install telnet*
    systemctl start xinetd.service
    systemctl start telnet.socket
    systemctl enable xinetd.service #开机启动
    systemctl enable telnet.socket #开机启动

  2. 修改telnet server端口

    修改/usr/lib/systemd/system/telnet.socket中的stream端口
    在防火墙处也打开该端口。
    systemctl daemon-reload

  3. 安装OpenSSH的依赖包

    yum install -y gcc gcc-c++ glibc make autoconf openssl openssl-devel pcre-devel pam-devel zlib* pam*

  4. OpenSSH p版本 (opens new window)的放到服务器,进行编译。注意OpenSSH版本如果不带p则只是OpenBSD使用。

    sudo ./configure --prefix=/usr/local/openssh --sysconfdir=/etc/ssh --with-pam --with-ssl-dir=/usr/local/openssl --with-md5-passwords --mandir=/usr/share/man --with-zlib=/usr/local/zlib
    sudo make
    sudo yum remove openssh-*
    sudo chmod 600 /etc/ssh/ssh_host*
    sudo make install

  5. 复制相应文件

    sudo cp ./contrib/redhat/sshd.init /etc/init.d/sshd
    sudo chkconfig --add sshd
    sudo cp /usr/local/openssh/sbin/sshd /usr/sbin/sshd
    sudo cp /usr/local/openssh/bin/ssh /usr/bin/ssh
    sudo cp /usr/local/openssh/bin/ssh-keygen /usr/bin/ssh-keygen

  6. 添加服务

    service sshd restart
    systemctl start sshd.service
    systemctl enable sshd.service
    sshd -t