Skip to content

Instantly share code, notes, and snippets.

@joebarker87
Created February 13, 2014 03:59
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joebarker87/8969509 to your computer and use it in GitHub Desktop.
Save joebarker87/8969509 to your computer and use it in GitHub Desktop.
Homebrew formula for OpenSSH with HPN and keychain patches
require 'formula'
class Openssh < Formula
homepage 'http://www.openssh.com/'
url 'http://ftp5.usa.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-6.3p1.tar.gz'
version '6.3p1'
sha1 '70845ca79474258cab29dbefae13d93e41a83ccb'
option 'with-brewed-openssl', 'Build with Homebrew OpenSSL instead of the system version'
option 'with-keychain-support', 'Add native OS X Keychain and Launch Daemon support to ssh-agent'
option 'with-hpn', 'Add support HPN patch set'
depends_on 'autoconf' => :build if build.with? 'keychain-support'
depends_on 'openssl' if build.with? 'brewed-openssl'
depends_on 'ldns' => :optional
depends_on 'pkg-config' => :build if build.with? "ldns"
def patches
p = []
p << 'http://mirror.shatow.net/freebsd/openssh/openssh-6.3p1-hpnssh14v2.diff.gz' if build.with? 'hpn'
p << 'https://gist.github.com/joebarker87/8969346/raw/c5a5638ea455395b90cba9b28698ed8f30816c04/post_hpn_keychain_patch.diff' if build.with? 'keychain-support'
p
end
def install
system "autoreconf -i" if build.with? 'keychain-support'
if build.include? "with-keychain-support"
ENV.append "CPPFLAGS", "-D__APPLE_LAUNCHD__ -D__APPLE_KEYCHAIN__"
ENV.append "LDFLAGS", "-framework CoreFoundation -framework SecurityFoundation -framework Security"
end
args = %W[
--with-libedit
--with-kerberos5
--prefix=#{prefix}
--sysconfdir=#{etc}/ssh
]
args << "--with-ssl-dir=#{Formula.factory('openssl').opt_prefix}" if build.with? 'brewed-openssl'
args << "--with-ldns" if build.with? "ldns"
# Sometimes when Apple ships security update, the libraries get
# updated while the headers don't. Disable header/library version
# check when using system openssl to cope with this situation.
args << "--without-openssl-header-check" if not build.with? 'brewed-openssl'
system "./configure", *args
system "make"
system "make install"
end
def caveats
if build.include? "with-keychain-support"
<<-EOS.undent
For complete functionality, please modify:
/System/Library/LaunchAgents/org.openbsd.ssh-agent.plist
and change ProgramArugments from
/usr/bin/ssh-agent
to
#{HOMEBREW_PREFIX}/bin/ssh-agent
After that, you can start storing private key passwords in
your OS X Keychain.
EOS
end
end
end
@daenney
Copy link

daenney commented Sep 19, 2014

Do you happen to have an idea if this still works on 6.6p1?

@daenney
Copy link

daenney commented Sep 19, 2014

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