【干货】CentOS下升级openssh版本

前端之家收集整理的这篇文章主要介绍了【干货】CentOS下升级openssh版本前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

前言

CentOS 6.x 和 7.x 的断裂带来很多麻烦,习惯SysV下面的init.d脚本后,转systemd很不适应,之前还花了点时间学systemd,但是可能是年龄大了,老是记不住命令,以后还是转回ubuntu去吧。

@H_404_4@一,安装telnet

升级个ssh,为什么要装telnet?因为很多人在管理服务器的时候,用的就是ssh远程连接,升级ssh失败的话连接会断开,所以必须先装个telnet,用telnet登录上去操作。

yum -y install telnet-server.x86_64

各自系统版本不一样可能telnet server叫不同名字,安装前用 yum search 搜一下就知道了。
装好后,更改配置文件,允许telnet远程连接:

nano /etc/xinetd.d/telnet

disable = yes改为 disable = no退出保存。
然后启动telnet服务:

service xinetd start

或者:

systemctl start xinetd

如果有开防火墙,最好先把防火墙关掉:

service iptables stop
chkconfig iptables off

或者:

systemctl stop firewalld
systemctl disable firewalld

然后在客户端登录一下试试,这里注意一点,如果想用root用户登录,还要再改一点配置:

nano /etc/securetty

在末尾添加几行:

pts/0
pts/1
pts/2
pts/3
pts/4
...

最好多加几个,因为你也不知道你的telnet连接对应的是几号。
添加好之后重启xinetd服务,就可以用root登录了。

二,升级ssh

注意,从这里开始,就要用刚刚装好的telnet登录来操作了。
关闭ssh

service sshd stop

或者:

systemctl stop sshd

然后安装openssl的开发版,编译openssh时需要它:

yum install -y openssl openssl-devel

安装好之后,去https://www.openssh.com/portable.html下载openssh安装包,这里要注意,openssh本来是给FreeBSD开发的,所以这里要下载的是它的Portable版本,这个版本才能在linux下安装,这个版本名字里面都带p1
我们下载openssh-7.4p1.tar.gz,然后运行

tar zxvf openssh-7.4p1.tar.gz
cd openssh-7.4p1

接下来,可以参考官方的安装文档:

2. Building / Installation
--------------------------

To install OpenSSH with default options:

./configure
make
make install

This will install the OpenSSH binaries in /usr/local/bin,configuration files
in /usr/local/etc,the server in /usr/local/sbin,etc. To specify a different
installation prefix,use the --prefix option to configure:

./configure --prefix=/opt
make
make install

Will install OpenSSH in /opt/{bin,etc,lib,sbin}. You can also override
specific paths,for example:

./configure --prefix=/opt --sysconfdir=/etc/ssh
make
make install

This will install the binaries in /opt/{bin,sbin},but will place the
configuration files in /etc/ssh.

If you are using Privilege Separation (which is enabled by default)
then you will also need to create the user,group and directory used by
sshd for privilege separation.  See README.privsep for details.

完整版安装指南:http://ftp.openbsd.org/pub/OpenBSD/OpenSSH/portable/INSTALL
其实如果没有特殊需求,就是三个命令:

./configure
make
make install

不出意外的话,运行

ssh -V

能看到版本已经更新,然后再启动sshd

service sshd restart

或者:

systemctl restart sshd

最后把telnet删掉,把防火墙恢复起来。

原文链接:https://www.f2er.com/centos/374617.html

猜你在找的CentOS相关文章