Skip to content

Instantly share code, notes, and snippets.

Last active April 18, 2017 00:26
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Remotely install Homebrew over ssh.

Look up OS X release.

there$ sw_vers -productVersion

Go to and get the best release of Command Line Tools for Xcode. For example, the latest version for OS X 10.9 is

After downloading the DMG, run the script to extract the PKG file, copy it to the remote host, and install everything.

here:Downloads$ ./ me@there [commandlinetools*.dmg]
#! /bin/bash -ex
# First download the OS X Command Line Tools for Xcode, then run this
# script to remotely install Homebrew.
# mount up the DMG
mnt=$(hdiutil attach "$dmg" |grep -o '/Volumes/.*')
# get the name of the PKG
pkg=$(find "$mnt" -iname '*.pkg')
# copy it over
rsync "$pkg" "$there:"
# strip off the local path
pkg=$(basename "$pkg")
set +e
# remotely extract/install the package
ssh -t "$there" "set -ex
xcode-select -p ||sudo installer -pkg \"$pkg\" -target /
xcode-select -p
! brew info
# TODO: get rid of the tty so ruby doesn't wait for user
ruby -e \"\$(curl -fsSL\"
brew info
brew doctor
# unmount
hdiutil detach "$mnt"
Copy link

dotysan commented Apr 18, 2017

Hrmm...think I need to work a sudo xcodebuild -license into teh process nowadays.

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