#!/bin/bash # # Build CentOS 6 RPM for newer version of OpenSSH # # THIS SCRIPT MUST BE EXECUTED ON A CENTOS 6 MACHINE. # # 2022-01-20 jms1 - worked for OpenSSH-8.8p1 set -e ######################################## # The RPM we will be building RPM_VER="8.8p1" RPM_REL="1" RPM_AUTHOR="John Simpson " ######################################## # OpenSSH # Note: MIRROR_URL must end with '/' OPENSSH_VER="8.8p1" MIRROR_URL="https://cdn.openbsd.org/pub/OpenBSD/OpenSSH/portable/" ######################################## # Dependency `x11-ssh-askpass` # # The original source, http://www.jmknoble.net/software/x11-ssh-askpass/ # is missing or unstable, so we will need to manually specify the URL where # this file can be downloaded. The version needs to match what's in the # `%define aversion` line in the OpenSSH spec file. ASKPASS_VER="1.2.4.1" ASKPASS_URL="https://mirrors.slackware.com/slackware/slackware-14.2/source/xap/x11-ssh-askpass/x11-ssh-askpass-1.2.4.1.tar.gz" ############################################################################### function usage { cat < "${HOME}/.rpmmacros" </dev/null 2>&1 then redline "Missing: command '$c'" FAIL=true fi done for p in rpm-build openssl-devel pam-devel imake gtk2-devel libXt-devel do if ! rpm -q $p >/dev/null then redline "Missing: RPM '$p'" FAIL=true fi done if $FAIL then exit 1 fi ######################################## # Create our /etc/pam.d/sshd file # (copied from what CentOS 6 installs) cat > "${HOME}/rpm/SOURCES/sshd.pam" < "${SPEC_FILE}" ######################################## # Extract the sshd_config file from the tarball, and make the edits we need blueline "Creating ${HOME}/rpm/SOURCES/sshd_config" tar xzf "${OPENSSL_SRC}" \ -O "openssh-${OPENSSH_VER}/sshd_config" \ | sed '/^#UsePAM no/i \ #\ # Note: CentOS 6 needs this to be "yes", otherwise password-based login\ # will fail when SELinux is active.\ #' \ | sed '/^#UsePAM no/a \ UsePAM yes' \ > "${HOME}/rpm/SOURCES/sshd_config" ######################################## # Download the x11-ssh-askpass source tarball AVERSION=$( awk '/^%global aversion /{print $3}' "${SPEC_FILE}" ) if [[ "${AVERSION}" != "${ASKPASS_VER}" ]] then redline "ERROR: x11-ssh-askpass version mismatch" echo "openssh spec wants '${AVERSION}'" echo "this script wants '${ASKPASS_VER}'" exit 1 fi if [[ ! -f "${HOME}/rpm/SOURCES/x11-ssh-askpass-${AVERSION}.tar.gz" ]] then blueline "Downloading x11-ssh-askpass-${AVERSION}.tar.gz" curl -Lo "${HOME}/rpm/SOURCES/x11-ssh-askpass-${AVERSION}.tar.gz" \ "${ASKPASS_URL}" fi ############################################################################### # # Build the RPMs rpmbuild -ba \ --define "_topdir ${HOME}/rpm" \ --define "packager ${RPM_AUTHOR}" \ --define "vendor Voalte, Inc." \ --define "dist .el6" \ "${SPEC_FILE}"