Created
March 22, 2017 12:47
-
-
Save krejac/6db8f8a9a9a48482a85c1b08ffdccbed to your computer and use it in GitHub Desktop.
ssh to an iCloud connected mac using Back To My Mac
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
#!/bin/bash | |
ACCOUNT=$(echo "show Setup:/Network/BackToMyMac" | scutil | sed -n 's/.* : *\(.*\).$/\1/p') | |
if [ ! -n "$1" ]; then | |
echo "ssh to which Mac? " | |
read MAC | |
# Uncomment the following two lines if you need to login to the remote host with a different user than the current local user. | |
#echo "As who? " | |
#read USER | |
if [[ USER ]]; then | |
ssh $USER"@"$MAC"."$ACCOUNT | |
else | |
ssh $MAC"."$ACCOUNT | |
fi | |
else | |
ssh $1"."$ACCOUNT | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment