How To Use iCloud To Remotely SSH Into Your Home Mac

Posted on the 25 July 2012 by Skateroren @ProgramsAlive
Step 1: The first step is to make sure that Back to My Mac is enabled on all the Macs in question. This is achieved by navigating to System Preferences > iCloud > Back to My Mac.

Step 2: To actually gain an SSH connection to the remote Mac, you will need to know the Back to My Mac account number. Open up an instance of the Terminal application and run the following command: dns-sd -E

Step 3: Once the account number is know, run the following command in Terminal to make an SSH connection to the remote machine: ssh -2 -6 username@computername.[ACCOUNT NUMBER].members.btmm.icloud.com
So there you have it. Using the iCloud network to remotely SSH into another iCloud enabled Mac is relatively simple and only involves typing a few lines from the Terminal app. To complete step 3 every time you want to do this and it might be an issue for some, simply add the following to ~/.ssh/config:
Host mac-remote
User username
HostName computername.[accountnumber].members.btmm.icloud.com
AddressFamily inet6
Protocol 2
Once the above has been completed, you can then replace step 2 with a much simpler string in the Terminal: ssh mac-remote