开发者社区> 问答> 正文

在 CentOS7 里安装  openssh-7.9p1

CentOS 7.5的openssh版本是 openssh-7.4p1-16.el7.x86_64,如需使用 openssh-7.9p1 版本,可参考下列。


过程:


1.先安装新版本的openssl,如openssl-1.1


2.yum install -y pam-devel openssl-devel # 安装相应的组件


3.wget https://ftp.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-7.9p1.tar.gz # 下载安装文件


4.tar xzvf openssh-7.9p1.tar.gz # 解压


5.cd openssh-7.9p1 # 进到文件目录


6../configure -prefix=/usr -sysconfdir=/etc/ssh -with-md5-passwords -with-pam -with-ssl-dir=/usr/include/openssl -without-hardening # 配置


7.make # 编译


8.mv /etc/ssh /etc/ssh-bak # 移走现有的ssh配置目录


9.make install # 安装


10.echo "PermitRootLogin yes" >> /etc/ssh/sshd_config # 允许root用户远程登录


11.cp contrib/redhat/sshd.init /etc/init.d/sshd # 复制sshd启动文件


12.chmod +x /etc/init.d/sshd # 给执行权限


13.chkconfig --add sshd # 添加服务


14.chkconfig sshd on # 设置自动启动


15.vi /usr/lib/systemd/system/sshd.service # 编辑配置文件,注释掉相关行,禁止自动启动,因为发现安装新版本openssh后,日志不断记录启动失败和自动启动
[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




16.systemctl daemon-reload # 重载服务


17./etc/init.d/sshd restart # 重启sshd服务




参考:
* https://bugzilla.redhat.com/show_bug.cgi?id=1381997
* https://serverfault.com/questions/838325/sshd-is-already-running-though-keeps-trying-to-start
* https://ngx.hk/2017/01/08/centos%E4%BD%BF%E7%94%A8rpmbuild%E5%8D%87%E7%BA%A7openssh%E5%88%B0openssh-7-4p1.html

展开
收起
dongshan8 2018-12-28 09:24:51 4820 0
0 条回答
写回答
取消 提交回答
问答排行榜
最热
最新

相关电子书

更多
CentOS Nginx PHP JAVA 多语言镜像使用手 立即下载
CentOS Nginx PHP JAVA多语言镜像使用手册 立即下载
低代码开发师(初级)实战教程 立即下载