Skip to content

Instantly share code, notes, and snippets.

@thenoseman
Forked from fumiyas/openssh-build-static.sh
Created December 23, 2018 11:07
Show Gist options
  • Save thenoseman/a42d2530747abc9410bff8e05c432b52 to your computer and use it in GitHub Desktop.
Save thenoseman/a42d2530747abc9410bff8e05c432b52 to your computer and use it in GitHub Desktop.

Revisions

  1. @fumiyas fumiyas created this gist Oct 4, 2017.
    46 changes: 46 additions & 0 deletions openssh-build-static.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,46 @@
    #!/bin/sh

    set -u
    set -e
    umask 0077

    prefix="/opt/openssh"
    top="$(pwd)"
    root="$top/root"
    build="$top/build"

    export CPPFLAGS="-I$root/include -L."

    rm -rf "$root" "$build"
    mkdir -p "$root" "$build"

    gzip -dc dist/zlib-*.tar.gz |(cd "$build" && tar xf -)
    cd "$build"/zlib-*
    ./configure --prefix="$root" --static
    make
    make install
    cd "$top"

    gzip -dc dist/openssl-*.tar.gz |(cd "$build" && tar xf -)
    cd "$build"/openssl-*
    ./config --prefix="$root" no-shared
    make
    make install
    cd "$top"

    gzip -dc dist/openssh-*.tar.gz |(cd "$build" && tar xf -)
    cd "$build"/openssh-*
    cp -p "$root"/lib/*.a .
    [ -f sshd_config.orig ] || cp -p sshd_config sshd_config.orig
    sed \
    -e 's/^#\(PubkeyAuthentication\) .*/\1 yes/' \
    -e '/^# *Kerberos/d' \
    -e '/^# *GSSAPI/d' \
    -e 's/^#\([A-Za-z]*Authentication\) .*/\1 no/' \
    sshd_config.orig \
    >sshd_config \
    ;
    ./configure --prefix="$prefix" --with-privsep-user=nobody --with-privsep-path="$prefix/var/empty"
    make
    #make install
    cd "$top"