Skip to content

Instantly share code, notes, and snippets.

@nerdlich
Last active September 7, 2016 18:39
Show Gist options
  • Save nerdlich/d4e2f07958387926239d to your computer and use it in GitHub Desktop.
Save nerdlich/d4e2f07958387926239d to your computer and use it in GitHub Desktop.
Script to connect to a headless Linux Crashplan server from OS X
#!/bin/bash
if [ "$1" == '' ]; then echo "Please provide a hostname to connect."; exit 1; fi
if [ $(whoami) != 'root' ]; then echo "Need to run with sudo"; exit 1; fi
host=$1
# get secrets
remote_secret=$(ssh root@$host "cat /var/lib/crashplan/.ui_info | cut -d',' -f2")
local_secret=$(cat /Library/Application\ Support/CrashPlan/.ui_info | cut -d',' -f2)
# write setting for remote (GNU sed)
echo -n "4200,$remote_secret,127.0.0.1" > /Library/Application\ Support/CrashPlan/.ui_info
sed -i 's/4243/4200/' /Library/Application\ Support/CrashPlan/ui_${SUDO_USER}.properties
# ssh tunnel
ssh -f -L 4200:localhost:4243 $host sleep 30
# start app
/Applications/CrashPlan.app/Contents/MacOS/CrashPlan >/dev/null 2>&1 &
sleep 10
# revert config change (GNU sed)
echo -n "4243,$local_secret,127.0.0.1" > /Library/Application\ Support/CrashPlan/.ui_info
sed -i 's/4200/4243/' /Library/Application\ Support/CrashPlan/ui_${SUDO_USER}.properties
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment