Skip to content

Instantly share code, notes, and snippets.

@ChaosJohn
Forked from skyisle/icloud-ssh
Created January 7, 2016 04:20
Show Gist options
  • Save ChaosJohn/5abee5e1993e26cad381 to your computer and use it in GitHub Desktop.
Save ChaosJohn/5abee5e1993e26cad381 to your computer and use it in GitHub Desktop.
Shell script to connect icloud host through ssh
#!/bin/bash
if [ ! -n "$1" ]
then
echo "Usage: `basename $0` hostname"
exit $E_BADARGS
fi
HOSTNAME=$1
DOMAIN=$(echo show Setup:/Network/BackToMyMac | scutil | sed -n 's/.* : *\(.*\).$/\1/p')
echo "Connecting to :" ${HOSTNAME}.${DOMAIN}"..."
ssh ${HOSTNAME}.${DOMAIN}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment