Skip to content

Instantly share code, notes, and snippets.

@surjikal
Last active October 9, 2025 12:16
Show Gist options
  • Select an option

  • Save surjikal/aaf0729af90bdc83064b to your computer and use it in GitHub Desktop.

Select an option

Save surjikal/aaf0729af90bdc83064b to your computer and use it in GitHub Desktop.
Compile OpenSSH Portable on OSX / MacOS
#!/usr/bin/env bash
brew install openssl
git clone git://anongit.mindrot.org/openssh.git
cd openssh
# The './configure' script does not exist, so we have to build it
autoreconf
mkdir dist
# Get the dir of the openssl install...
BREW_OPENSSL_DIR="$(brew --prefix openssl)"
# If you can't get the command above to work... try one of these:
# BREW_OPENSSL_DIR=/opt/homebrew/opt/openssl
# BREW_OPENSSL_DIR=/usr/local/opt/openssl
./configure \
--prefix="$(pwd)/dist" \
LDFLAGS="-L${BREW_OPENSSL_DIR}/lib" \
CPPFLAGS="-I${BREW_OPENSSL_DIR}/include"
make
@PyvesB

PyvesB commented Aug 23, 2021

Copy link
Copy Markdown

@surjikal, im my case, I'm currently testing macOS Monterey beta. It ships a newer version of OpenSSH, 8.6. OpenSSH supports comments at the end of config lines since version 8.5, but this broke the parsing of ProxyCommand. Fortunately, this was reported (https://bugzilla.mindrot.org/show_bug.cgi?id=3288) and fixed. Recompiling OpenSSH from latest source code is my workaround, until version 8.7 of OpenSSH is released - at that point I'll simply be able to install it via Brew.

@iamh2o

iamh2o commented Aug 27, 2021

Copy link
Copy Markdown

I needed a fresh install and brew was not working, nor manual normal building.

@oxtoacart

Copy link
Copy Markdown

This is great, thanks!

FYI for people on M1 Macs, homebrew installs in /opt/homebrew, so the configure command is slightly different:

./configure \
  --prefix="$(pwd)/dist" \
  LDFLAGS="-L/opt/homebrew/opt/openssl/lib" \
  CPPFLAGS="-I/opt/homebrew/opt/openssl/include"

@surjikal

surjikal commented Feb 1, 2024

Copy link
Copy Markdown
Author

@oxtoacart cool! Your comment gave me an idea... thank you!

gist updated to get the install location from brew, instead of hardcoding the path.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment