系统版本为RHEL7如下
cat /etc/redhat-release
Red Hat Enterprise Linux Server release 4.2 (Maipo)
(1)openssh-7.7p1的下载
官网地址:http://www.openssh.com/portable.html
文件名称:openssh-7.7p1.tar.gz
(2)安装的过程中需要x11-ssh-askpass-1.2.4.1.tar.gz,下载地址如下:
https://src.fedoraproject.org/repo/pkgs/openssh/x11-ssh-askpass-1.2.4.1.tar.gz/8f2e41f3f7eaa8543a2440454637f3c3/x11-ssh-askpass-1.2.4.1.tar.gz 或者
http:
//ftp
.riken.jp
/Linux/momonga/6/Everything/SOURCES/x11-ssh-askpass-1
.2.4.1.
tar
.gz
(3)使用ftp的方式传到Linux主机上。
ftp 主机ip
输入账号密码
binary
cd 对应的文件夹
mget *.*
下载相关的文件后退出
quit
2、系统要求
(1)查看tar包里面的INSTALL文件,有要求
Zlib 1.1.4 or 1.2.1.2 or greater (earlier 1.2.x versions have problems):
libcrypto (LibreSSL or OpenSSL >= 1.0.1 < 1.1.0)
(2)通过rpm -q zlib-devel查询版本号。
3、必要软件的安装
因我的系统有些包没有安装,为了解决依赖问题,我选择使用光盘iso文件内的RPMS进行yum安装。
(1)挂载iso文件。
mount /data/iso/rhel-server-7.2-x86_64-dvd.iso /mnt/dvd/
yum install openssl-devel.x86_64
yum install krb5-devel.x86_64
4、打包Openssh7.7p1
(1)创建文件,解压缩
mkdir -p /usr/src/redhat/{SOURCES,SPECS}
cd /usr/src/redhat/SOURCES/
tar xf openssh-7.7p1.tar.gz
cp openssh-7.7p1/contrib/redhat/openssh.spec /usr/src/redhat/SPECS/
chown sshd:sshd /usr/src/redhat/SPECS/ -R
cp /usr/src/redhat/SOURCES/openssh-7.7p1.tar.gz ~/rpmbuild/SOURCES/
cd /usr/src/redhat/SPECS/
# Do we want to disable building of x11-askpass? (1=yes 0=no)
%define no_x11_askpass 0
# Do we want to disable building of gnome-askpass? (1=yes 0=no)
%define no_gnome_askpass 0
将0修改为1,即
# Do we want to disable building of x11-askpass? (1=yes 0=no)
%define no_x11_askpass 1
# Do we want to disable building of gnome-askpass? (1=yes 0=no)
%define no_gnome_askpass 1
(3)将下载的x11-ssh-askpass-1.2.4.1.tar.gz复制到/root/rpmbuild/SOURCES/文件内
cp x11-ssh-askpass-1.2.4.1.tar.gz /root/rpmbuild/SOURCES/
(4)打包
rpmbuild -ba openssh.spec
发现错误。提示我的openssl-devel < 1.1的条件不满足。实际查询版本为1.0.1e满足条件。所以从openssh.spec里面103行删除该判断条件
BuildRequires: openssl-devel < 1.1
删除上面一行判断条件后继续打包。无提示错误。
(5)查看生成的rpm包。
cd /root/rpmbuild/RPMS/x86_64/
通过ls可以看到已经生成如下包
openssh-7.7p1-1.el6.x86_64.rpm
openssh-clients-7.7p1-1.el6.x86_64.rpm
openssh-debuginfo-7.7p1-1.el6.x86_64.rpm
openssh-server-7.7p1-1.el6.x86_64.rpm
5、安装telnet并测试ssh。因为之前已经使用过telnet,这里直接启动服务。防火墙已经关闭。不需要设置。
systemctl start xinetd
systemctl start telnet.socket
6、通过telnet登录主机,然后执行
rpm -Uvh *.*
通过rpm -q 查看版本已经升级成功
7、测试ssh登录,发现无法登录。
(1)使用systemctl status sshd.service
发现报错如下:
PAM unable to dlopen(/lib64/security/pam_stack.so): /lib64/security/pam_stack.so: cannot open shared object file: No such file or directory
PAM adding faulty module: /lib64/security/pam_stack.so
经过排查发现是ssh rpm 升级后会修改/etc/pam.d/sshd 文件,如下:
#%PAM-1.0
auth required pam_stack.so service=system-auth
account required pam_nologin.so
account required pam_stack.so service=system-auth
password required pam_stack.so service=system-auth
session required pam_stack.so service=system-auth
修改为之前的即可。修改后的文件如下:
#%PAM-1.0
auth required pam_sepermit.so
auth include password-auth
account required pam_nologin.so
account include password-auth
password include password-auth
# pam_selinux.so close should be the first session rule
session required pam_selinux.so close
session required pam_loginuid.so
# pam_selinux.so open should only be followed by sessions to be executed in the user context
session required pam_selinux.so open env_params
session optional pam_keyinit.so force revoke
session include password-auth
(2)还可能出现权限的报错
使用chown sshd:sshd 文件,修改文件权限即可。
8、结尾工作
(1)关闭telnet
systemctl stop xinetd
systemctl stop telnet.socket
(2)确认sshd服务
chkconfig
发现服务已经ON
如果没有ON
可以用chkconfig sshd on 开启
(3)卸载光盘
unmount /mnt/dvd/