Created
December 29, 2015 15:38
-
-
Save pedropalmero/e3d950a66f5ad0b5c0af to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "formula" | |
class Openssh < Formula | |
homepage "http://www.openssh.com/" | |
url "http://ftp.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-6.8p1.tar.gz" | |
version "6.8p1" | |
sha256 "3ff64ce73ee124480b5bf767b9830d7d3c03bbcb6abe716b78f0192c37ce160e" | |
bottle do | |
root_url "https://homebrew.bintray.com/bottles-dupes" | |
sha256 "d8b11af1030a8b73240b1b780971cdc8e2e14d29d91744e6c2d17a726e1b81bf" => :yosemite | |
sha256 "75a3448223d8e63e24a3755091a46151070ff93c7c89a7c3b4aaa1287a8bbcad" => :mavericks | |
sha256 "0112148ed980edb2288e4ef4a07952c7203d452d3b4858d13f11f2815c115e84" => :mountain_lion | |
end | |
option "with-keychain-support", "Add native OS X Keychain and Launch Daemon support to ssh-agent" | |
option "with-libressl", "Build with LibreSSL instead of OpenSSL" | |
depends_on "autoconf" => :build if build.with? "keychain-support" | |
depends_on "openssl" => :recommended | |
depends_on "libressl" => :optional | |
depends_on "ldns" => :optional | |
depends_on "pkg-config" => :build if build.with? "ldns" | |
if build.with? "keychain-support" | |
patch do | |
url "https://trac.macports.org/export/138238/trunk/dports/net/openssh/files/0002-Apple-keychain-integration-other-changes.patch?rev=134753" | |
sha256 "bcc9b9103fe2333ec6053fcdf5aac51ca2f07138cd05b66c37c01c92585ed778" | |
end | |
end | |
# Patch for SSH tunnelling issues caused by launchd changes on Yosemite | |
patch do | |
url "https://trac.macports.org/export/135165/trunk/dports/net/openssh/files/launchd.patch" | |
sha256 "02e76c153d2d51bb0b4b0e51dd7b302469bd24deac487f7cca4ee536928bceef" | |
end | |
def install | |
system "autoreconf -i" if build.with? "keychain-support" | |
if build.with? "keychain-support" | |
ENV.append "CPPFLAGS", "-D__APPLE_LAUNCHD__ -D__APPLE_KEYCHAIN__" | |
ENV.append "LDFLAGS", "-framework CoreFoundation -framework SecurityFoundation -framework Security" | |
end | |
ENV.append "CPPFLAGS", "-D__APPLE_SANDBOX_NAMED_EXTERNAL__" | |
args = %W[ | |
--with-libedit | |
--with-pam | |
--with-kerberos5 | |
--prefix=#{prefix} | |
--sysconfdir=#{etc}/ssh | |
] | |
if build.with? "libressl" | |
args << "--with-ssl-dir=#{Formula["libressl"].opt_prefix}" | |
else | |
args << "--with-ssl-dir=#{Formula["openssl"].opt_prefix}" | |
end | |
args << "--with-ldns" if build.with? "ldns" | |
system "./configure", *args | |
system "make" | |
system "make", "install" | |
end | |
def caveats | |
if build.with? "keychain-support" then <<-EOS.undent | |
NOTE: replacing system daemons is unsupported. Proceed at your own risk. | |
For complete functionality, please modify: | |
/System/Library/LaunchAgents/org.openbsd.ssh-agent.plist | |
and change ProgramArguments from | |
/usr/bin/ssh-agent | |
to | |
#{HOMEBREW_PREFIX}/bin/ssh-agent | |
You will need to restart or issue the following commands | |
for the changes to take effect: | |
launchctl unload /System/Library/LaunchAgents/org.openbsd.ssh-agent.plist | |
launchctl load /System/Library/LaunchAgents/org.openbsd.ssh-agent.plist | |
Finally, add these lines somewhere to your ~/.bash_profile: | |
eval $(ssh-agent) | |
function cleanup { | |
echo "Killing SSH-Agent" | |
kill -9 $SSH_AGENT_PID | |
} | |
trap cleanup EXIT | |
After that, you can start storing private key passwords in | |
your OS X Keychain. | |
EOS | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Install:
Do not forget to do all the changes that are required after install