redhat7 升级openssh

痴心易碎 提交于 2019-12-05 16:36:08

部署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

 

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!