upgrade openSSH

准备

切换到root用户

[code]su – root[/code]

备份

将ssh配置目录备份

[code]cp -rf /etc/ssh /etc/ssh_bak[/code]

升级

使用yum安装编译安装需要的软件包(来源于网络),Ubuntu用apt-get

[code]yum install gcc openssl-devel pam-devel rpm-build[/code]

下载openssh 7.5p1或最新版本版本

[code]
# 官方各版本列表 https://openbsd.hk/pub/OpenBSD/OpenSSH/portable/
wget http://mirror.internode.on.net/pub/OpenBSD/OpenSSH/portable/openssh-7.5p1.tar.gz
[/code]

解压

[code]tar -zxvf openssh-7.2p2.tar.gz[/code]

进入安装目录

[code]cd openssh-7.2p2[/code]

编译安装新版本openssh(编译遇到了坑,最终参考这里解决,后期通过核查猜测与–with-pam未加上有关)

[code]
./configure –prefix=/usr –sysconfdir=/etc/ssh –with-pam –with-zlib –with-md5-passwords
# 编译要安装pam模块,否则登录会因为认证方式被拒接 Permission denied (publickey,password,keyboard-interactive).
[/code]

编译

[code]
make
[/code]

安装

[code]
make install
# 安装过程中可能出现警告,不支持的配置项,可以忽略,安装好后可以注释掉这个配置
# /etc/ssh/sshd_config line 81: Unsupported option GSSAPIAuthentication
# /etc/ssh/sshd_config line 83: Unsupported option GSSAPICleanupCredentials
[/code]

重置ssh服务

[code]
# 重启sshd之前确保以下两点是否配置正确,
# 1、开启配置 UsePAM yes; #没配置会登录失败
# 2、默认禁止root登录,若只有root用户,需要开启root登录:注释PermitRootLogin without-password,启用PermitRootLogin yes;

service sshd restart
or
/etc/init.d/sshd restart
[/code]

最后查看版本
ssh -V

不要断开当前连接 不要断开当前连接 不要断开当前连接

另起一个终端,测试root用户或其他用户是否正常登录。

 

  • 参考 http://sun-ao.github.io/2016/06/13/update-openssh-to-7-2p2/