Giter VIP home page Giter VIP logo

openssh-rpms's Introduction

Backport OpenSSH RPM / SRPM for CentOS

A simple script to backport latest OpenSSH RPMs for CentOS/RHEL (like) distros.

Similar Project: Backport OpenSSH for Debian / Ubuntu distros

Supported (tested) Distro:

  • CentOS 5/6/7/8/Stream 8/9
  • Amazon Linux 1/2/2023
  • UnionTech OS Server 20
  • openEuler 22.03 (LTS-SP1)
  • AnolisOS 7.9/8.6

Current Version:

The build script reads version.env for actual version definitions.

Build Requirements:

yum groupinstall -y "Development Tools"
yum install -y imake rpm-build pam-devel krb5-devel zlib-devel libXt-devel libX11-devel gtk2-devel perl perl-IPC-Cmd

# For CentOS5 only:
yum install -y gcc44

Usage

Build RPMs

  1. Install build requirements listed above.
  2. Edit version.env file if necessary.
  3. Download source packages.
    ./pullsrc.sh
    if any error comes up, manually download the source files into the downloads dir.
  4. Run the script to build RPMs.
    ./compile.sh

Install RPMs

# Go go the generated RPMS directory.
cd $(./compile.sh RPMDIR)
pwd
ls
# you will find multiple RPM files in this directory.
# you may copy them to other machines, and continue following steps there.

# Backup current SSH config
[[ -f /etc/ssh/sshd_config ]] && mv /etc/ssh/sshd_config /etc/ssh/sshd_config.$(date +%Y%m%d)

# Install rpm packages. Exclude all debug packages.
find . ! -name '*debug*' -name '*.rpm' | xargs sudo yum --disablerepo=* localinstall -y

# in case host key files got permissions too open.
chmod -v 600 /etc/ssh/ssh_host_*_key

# For CentOS7+:
# in some cases previously installed systemd unit file is left on disk after upgrade.
# causes systemd mixing unit files and initscripts units provided by this package.
if [[ -d /run/systemd/system && -f /usr/lib/systemd/system/sshd.service ]]; then
    mv /usr/lib/systemd/system/sshd.service /usr/lib/systemd/system/sshd.service.$(date +%Y%m%d)
    systemctl daemon-reload
fi

# Check Installed version:
ssh -V && /usr/sbin/sshd -V

# Restart service
service sshd restart

DO NOT DISCONNECET current ssh shell yet, open a NEW shell and login to you machine to verify that sshd is working properly.

Trouble shoot

You may get complains during the yum localinstall process. It's mostly because some subpackages depend on the main openssh package, upgrading only the main package won't fit in their dependencies.

Commonly these packages are needed to be erased before installing built RPMs.

yum erase openssh-askpass openssh-keycat openssh-cavs openssh-askpass openssh-askpass-gnome openssh-debuginfo

If still not satisfied, you may try the final wepon: FORCED INSTALL.

rpm -ivh --force --nodeps --replacepkgs --replacefiles openssh-*.rpm

Use Docker

TL;DR

# Define output directory
OUTPUT="/tmp/openssh-rpms"
# Specify build os and versions
declare -A MAPPING
MAPPING["amazonlinux2023"]="amzn2023"
MAPPING["amazonlinux2"]="amzn2"
MAPPING["amazonlinux1"]="amzn1"
MAPPING["centos-stream9"]="el7"
MAPPING["centos-stream8"]="el7"
MAPPING["centos7"]="el7"
MAPPING["centos6"]="el6"
# CentOS 5 is NOT valid.
# MAPPING["centos5"]="el5"

for VERSION in "${!MAPPING[@]}";
do
  DIST=${MAPPING[$VERSION]}
  echo "Create for OS: ${VERSION}"
  mkdir -p $OUTPUT/$VERSION
  # Run the builder container
  docker run -it --rm \
             -v $OUTPUT/$VERSION:/data/$DIST/RPMS \
             chowrex/openssh-rpms:$VERSION
done

For more details, see file docker.README.md

Security Notes

This package provide following options in /etc/ssh/sshd_config to work like triditional sshd.

PubkeyAcceptedAlgorithms +ssh-rsa
PermitRootLogin yes
PasswordAuthentication yes
UseDNS no
UsePAM yes
KexAlgorithms -diffie-hellman-group1-sha1,diffie-hellman-group1-sha256,diffie-hellman-group14-sha1,diffie-hellman-group14-sha256,diffie-hellman-group15-sha256,diffie-hellman-group15-sha512,diffie-hellman-group16-sha256,diffie-hellman-group16-sha512,diffie-hellman-group17-sha512,diffie-hellman-group18-sha512,diffie-hellman-group-exchange-sha1,diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha512

openssh-rpms's People

Contributors

boypt avatar chowrex avatar jazzl0ver avatar lms1206 avatar usp-tme avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

openssh-rpms's Issues

大家要慎重啊

我是阿里云服务器centos6.3,运行了yum groupinstall -y "Development Tools"之后,整个服务器就不能用了,哭

wget refuses Let's Encrypt

sorry I don't have time to make PR but here is quick note.

on CentOS release 6.10 (Final)

pullsrc failed like this,

$ ./pullsrc.sh 
/usr/local/src/openssh-rpms/downloads /usr/local/src/openssh-rpms
Get: https://www.openssl.org/source//openssl-1.1.1t.tar.gz
--2023-04-14 11:03:07--  https://www.openssl.org/source//openssl-1.1.1t.tar.gz
Resolving www.openssl.org... 104.78.99.80, 2600:140b:2:9a6::c1e, 2600:140b:2:9a4::c1e
Connecting to www.openssl.org|104.78.99.80|:443... connected.
ERROR: cannot verify www.openssl.org’s certificate, issued by “/C=US/O=Let's Encrypt/CN=R3”:
  Issued certificate has expired.
To connect to www.openssl.org insecurely, use ‘--no-check-certificate’.
Aborted, error 5 in command: wget $OPENSSLMIR/$OPENSSLSRC

It seems wget and ca-certificate are too old on CentOS6.

$ wget https://www.openssl.org/source//openssl-1.1.1t.tar.gz
--2023-04-14 11:04:28--  https://www.openssl.org/source//openssl-1.1.1t.tar.gz
Resolving www.openssl.org... 104.78.99.80, 2600:140b:2:9a6::c1e, 2600:140b:2:9a4::c1e
Connecting to www.openssl.org|104.78.99.80|:443... connected.
ERROR: cannot verify www.openssl.org’s certificate, issued by “/C=US/O=Let's Encrypt/CN=R3”:
  Issued certificate has expired.
To connect to www.openssl.org insecurely, use ‘--no-check-certificate’.

FYI, quick googling told me using curl instead may fix this.

How can I use Libressl?

Libressl hidden software version is simpler than OpenSSL, but I failed to use libressl(static linked).

RPM 构建错误:/var/tmp/rpm-tmp.NUKkwS (%prep) 退出状态不好

./compile.sh occur a error

  • ./config shared zlib -fPIC
    Can't locate IPC/Cmd.pm in @inc (@inc contains: /opt/openssh-rpms-main/el7/BUILD/openssh-9.5p1/openssl/util/perl /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 . /opt/openssh-rpms-main/el7/BUILD/openssh-9.5p1/openssl/external/perl/Text-Template-1.56/lib) at /opt/openssh-rpms-main/el7/BUILD/openssh-9.5p1/openssl/util/perl/OpenSSL/config.pm line 19.
    BEGIN failed--compilation aborted at /opt/openssh-rpms-main/el7/BUILD/openssh-9.5p1/openssl/util/perl/OpenSSL/config.pm line 19.
    Compilation failed in require at /opt/openssh-rpms-main/el7/BUILD/openssh-9.5p1/openssl/Configure line 23.
    BEGIN failed--compilation aborted at /opt/openssh-rpms-main/el7/BUILD/openssh-9.5p1/openssl/Configure line 23.
    错误:/var/tmp/rpm-tmp.NUKkwS (%prep) 退出状态不好

RPM 构建错误:
/var/tmp/rpm-tmp.NUKkwS (%prep) 退出状态不好
Aborted, error 1 in command: rpmbuild -ba SPECS/openssh.spec --target $(uname -m) --define "_topdir $PWD" --define "opensslver ${OPENSSLVER}" --define "opensshver ${OPENSSHVER}" --define "opensshpkgrel ${PKGREL}" --define 'no_gtk2 1' --define 'skip_gnome_askpass 1' --define 'skip_x11_askpass 1'
trap: 用法:trap [-lp] [[参数] 信号声明 ...]

[HELP] how avoid git removed along with the old openssh !

yum remove openssh
Loaded plugins: fastestmirror
Resolving Dependencies
--> Running transaction check
---> Package openssh.x86_64 0:7.4p1-16.el7 will be erased
--> Processing Dependency: openssh = 7.4p1-16.el7 for package: openssh-server-7.4p1-16.el7.x86_64
--> Processing Dependency: openssh = 7.4p1-16.el7 for package: openssh-clients-7.4p1-16.el7.x86_64
--> Running transaction check
---> Package openssh-clients.x86_64 0:7.4p1-16.el7 will be erased
--> Processing Dependency: openssh-clients for package: git-1.8.3.1-23.el7_8.x86_64
--> Processing Dependency: openssh-clients for package: systemtap-client-4.0-13.el7.x86_64
---> Package openssh-server.x86_64 0:7.4p1-16.el7 will be erased
--> Running transaction check
---> Package git.x86_64 0:1.8.3.1-23.el7_8 will be erased
--> Processing Dependency: git = 1.8.3.1-23.el7_8 for package: perl-Git-1.8.3.1-23.el7_8.noarch
--> Processing Dependency: git for package: gettext-devel-0.19.8.1-3.el7.x86_64
---> Package systemtap-client.x86_64 0:4.0-13.el7 will be erased
--> Processing Dependency: systemtap-client = 4.0-13.el7 for package: systemtap-4.0-13.el7.x86_64
--> Running transaction check
---> Package gettext-devel.x86_64 0:0.19.8.1-3.el7 will be erased
--> Processing Dependency: gettext-devel for package: intltool-0.50.2-7.el7.noarch
---> Package perl-Git.noarch 0:1.8.3.1-23.el7_8 will be erased
---> Package systemtap.x86_64 0:4.0-13.el7 will be erased
--> Running transaction check
---> Package intltool.noarch 0:0.50.2-7.el7 will be erased
--> Finished Dependency Resolution

Dependencies Resolved

==================================================================================================================================================================================================================================================================================
 Package                                                                Arch                                                         Version                                                                Repository                                                       Size
==================================================================================================================================================================================================================================================================================
Removing:
 openssh                                                                x86_64                                                       7.4p1-16.el7                                                           @anaconda                                                       1.9 M
Removing for dependencies:
 gettext-devel                                                          x86_64                                                       0.19.8.1-3.el7                                                         @base                                                           1.4 M
 git                                                                    x86_64                                                       1.8.3.1-23.el7_8                                                       @base                                                            22 M
 intltool                                                               noarch                                                       0.50.2-7.el7                                                           @base                                                           166 k
 openssh-clients                                                        x86_64                                                       7.4p1-16.el7                                                           @anaconda                                                       2.5 M
 openssh-server                                                         x86_64                                                       7.4p1-16.el7                                                           @anaconda                                                       971 k
 perl-Git                                                               noarch                                                       1.8.3.1-23.el7_8                                                       @base                                                            57 k
 systemtap                                                              x86_64                                                       4.0-13.el7                                                             @base                                                           0.0  
 systemtap-client                                                       x86_64                                                       4.0-13.el7                                                             @base                                                            10 M

Transaction Summary
==================================================================================================================================================================================================================================================================================
Remove  1 Package (+8 Dependent packages)

Installed size: 40 M
Is this ok [y/N]: 


RPM build errors: Macro expanded in comment on line 116: %{compat_openssl}

使用openssh-9.7p1 + openssl-1.1.1k版本运行脚本后半部分时报错:
make: *** [Makefile:195: sshd.o] Error 1
make: *** Waiting for unfinished jobs....
In file included from openbsd-compat/openbsd-compat.h:218,
from includes.h:173,
from auth-rhosts.c:17:
openbsd-compat/bsd-misc.h:143:39: error: expected identifier or '(' before 'do'

define krb5_free_error_message(a,b) do { } while(0)

                                   ^~

openbsd-compat/bsd-misc.h:143:46: error: expected identifier or '(' before 'while'

define krb5_free_error_message(a,b) do { } while(0)

                                          ^~~~~

In file included from /usr/include/krb5/krb5.h:8694,
from /usr/include/krb5.h:8,
from auth.h:41,
from auth-rhosts.c:45:
/usr/include/et/com_err.h:38:20: error: conflicting types for 'error_message'
extern char const *error_message (long);
^~~~~~~~~~~~~
In file included from includes.h:170,
from auth-rhosts.c:17:
defines.h:725:43: note: previous declaration of 'error_message' was here

define krb5_get_err_text(context,code) error_message(code)

                                       ^~~~~~~~~~~~~

make: *** [Makefile:195: auth-rhosts.o] Error 1
error: Bad exit status from /var/tmp/rpm-tmp.AraQyV (%build)

RPM build errors:
Macro expanded in comment on line 116: %{compat_openssl}

Bad exit status from /var/tmp/rpm-tmp.AraQyV (%build)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.