部署telnet,防止ssh启动失败
1、关闭防火墙或者开放23端口
2、安装启动服务,并开启root访问
yum install -y telnet-server.x86_64 yum install -y telnet.x86_64 yum install -y xinetd.x86_64 systemctl enable xinetd.service systemctl enable telnet.socket systemctl start telnet.socket systemctl start xinetd mv /etc/securetty /etc/securetty.bak
部署open-ssh
#备份与卸载
mkdir /etc/ssh_oldbak/ mv /etc/ssh/* /etc/ssh_oldbak/ rpm -e `rpm -qa |grep openssh`
#安装依赖 yum install -y gcc gcc-c++ glibc make autoconf openssl openssl-devel pcre-devel pam-devel yum install -y pam* zlib*
#编译安装 cd openssh-7.9p1/ ./configure -prefix=/usr -sysconfdir=/etc/ssh -with-md5-passwords -with-pam -with-ssl-dir=/usr/include/openssl -without-hardening make && make install
#将原来备份的配置文件拷贝回来
mv /etc/ssh/sshd_config /etc/ssh/sshd_config.bak cp /etc/ssh_oldbak/sshd_config /etc/ssh/sshd_config
#从程序包拷贝可执行文件
cp contrib/redhat/sshd.init /etc/init.d/sshd chmod +x /etc/init.d/sshd
#添加到自启动 chkconfig --add sshd chkconfig sshd on
修改配置文件
vi /usr/lib/systemd/system/sshd.service
[Unit] Description=OpenSSH server daemon Documentation=man:sshd(8) man:sshd_config(5) # After=network.target sshd-keygen.service # Wants=sshd-keygen.service After=network.target [Service] # Type=notify # EnvironmentFile=/etc/sysconfig/sshd # ExecStart=/usr/sbin/sshd -D $OPTIONS ExecStart=/usr/sbin/sshd # ExecReload=/bin/kill -HUP $MAINPID # KillMode=process # Restart=on-failure # RestartSec=42s [Install] WantedBy=multi-user.target
修改配置文件
vi /etc/ssh/sshd_config
设置如下:
PermitRootLogin yes
PasswordAuthentication yes
注销sshd的配置文件(sshd_config)的如下配置:
#GSSAPIAuthentication yes
#GSSAPICleanupCredentials yes
#UsePAM yes
重启服务
systemctl restart sshd
systemctl enable sshd
----------------------------openssl 升级-----------------------------------------
1、如上第一步,先部署telnet
2、升级OpenSSl
1、查看原版本
openssl version -a
2、解压安装
tar zxvf openssl-1.1.1c.tar.gzcd openssl-1.0.1g
cd openssl-1.1.1c
./config --prefix=/usr/local/openssl #检查环境
./config -t
make #编译
make install #编译安装
cd /usr/local
ldd /usr/local/openssl/bin/openssl #检查函数库
echo "/usr/local/openssl/lib" >> /etc/ld.so.conf #添加所缺函数库
ldconfig -v #更新函数库
openssl/bin/openssl version #查看新安装的版本
which openssl #查看旧版本openssl命令在哪里
mv /bin/openssl /usr/bin/openssl.old #将旧版本openssl移除
ln -s /usr/local/openssl/bin/openssl /usr/bin/openssl #新版本制作软链接
openssl version 最后查看版本,更新完毕