Skip to content

Instantly share code, notes, and snippets.

@ljyloi
Last active November 4, 2022 11:12
Show Gist options
  • Save ljyloi/00c0cb5c411fc66409909fd14cb60059 to your computer and use it in GitHub Desktop.
Save ljyloi/00c0cb5c411fc66409909fd14cb60059 to your computer and use it in GitHub Desktop.
static-sshd build script
#!/bin/sh
set -ex
# run it to build a sshd for amd64
# docker run --rm -v $(pwd):/tmp -w /tmp -e ARCH=amd64 alpine /tmp/make.sh
# library version
OPENSSH_VERSION=V_8_5_P1
top="$(pwd)"
build="$top/build"
dist="$top/dist"
artifacts="$top/artifacts"
rm -rf "$build" "$dist"
mkdir -p "$build" "$dist" "$artifacts"
# add dependency
apk add build-base clang openssl-dev nghttp2-dev nghttp2-static libssh2-dev libssh2-static autoconf automake
apk add openssl-libs-static zlib-static || true
# download openssh
wget https://github.com/openssh/openssh-portable/archive/refs/tags/$OPENSSH_VERSION.tar.gz -O $dist/openssh-$OPENSSH_VERSION.tar.gz
gzip -dc $dist/openssh-*.tar.gz |(cd "$build" && tar xf -)
cd "$build"/openssh-*
# configure and make
export CC=clang
autoreconf
LDFLAGS="-static" PKG_CONFIG="pkg-config --static" ./configure --disable-shared --enable-static --with-privsep-user=nobody --with-privsep-path="/var/run/sshd" --sysconfdir=/etc/ssh
make -j4 V=1 LDFLAGS="-static -all-static -L. -Lopenbsd-compat"
cp $build/openssh*/sshd $artifacts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment