Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Remotely connect to a Mac via SSH using iCloud's network Network
If you're running two Macs with iCloud support (Lion or Mountain Lion), then you can use iCloud's network to remote SSH back into your home computer no matter where you are with just a few commands in Terminal.

The process is explained by the One Thing Well blog, but you need to set up a few things before you get started. First, you need to make sure Back to My Mac is enabled in iCloud (System Preferences > iCloud > Back to My Mac). Next, you need to set up your home computer for sharing if it isn't already. Head to System Preferences > Sharing and turn on at least File Sharing and Remote Login. With everything set, you can now remotely log in to your home computer using iCloud's network wherever you have internet access.

To start with, you need to do is find your Back to My Mac account number. In Terminal (Applications > Utilities), type:
dns-sd -E
The final nine digit number is your Back to My Mac account number. Next, it's time to SSH into your other machine:
 ssh -2 -6 username@computer-name.[account number].members.btmm.icloud.com 
If you don't know your username or computer name, head to System Preferences > Sharing on the destination computer and click on Remote Login. Your Computer name is listed at the top (if it's multiple words use the address with the dashes). Your username is listed on the line below Remote Login right before the @ symbol. You will need to do this before you try to SSH into your computer when you're away.

With that, you should have access to your Mac no matter where you are. Head over to One Thing Well for a few more tricks and shortcuts for using the iCloud network to remote SSH.

[kirkmc adds: I haven't tested this.]
    •    
  • Currently 2.69 / 5
  You rated: 1 / 5 (26 votes cast)
 
[29,619 views]  

Remotely connect to a Mac via SSH using iCloud's network | 9 comments | Create New Account
Click here to return to the 'Remotely connect to a Mac via SSH using iCloud's network ' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Remotely connect to a Mac via SSH using iCloud's network
Authored by: pajp on Aug 10, '12 07:49:27AM

You can also accomplish the same thing by choosing "Shell" -> "New Remote Connection" in Terminal, then select "Secure Shell (ssh)" in the service list. The "Server" list will be populated by SSH-enabled hosts on your LAN but also (after a few seconds) hosts available through Back To My Mac (there may also be a short delay after selecting the remote host in the Server list to the text field being populated with the necessary "ssh" command line to connect).

Some firewalls may block the IPSec necessary for BTMM to work.



[ Reply to This | # ]
Great feature, a few supplements
Authored by: lullabud on Aug 10, '12 08:46:28AM
I use this daily and it's really great. A few things…

1) It's easier to get your full domain name and available ssh computers by using dns-sd -B _ssh
2) Create a .ssh/config option for your new btmm hostname to make it easier. Mine are all hostname-btmm.
3) Expect interruptions. I've consistently found that my ssh sessions are prematurely terminated. For this reason I always connect to screen when working over btmm.


Another thing I couldn't figure out was how to add the btmm domain into the dns search, which would let you skip 1 and 2… If anybody knows how, please post it!
Edited on Aug 10, '12 08:47:00AM by lullabud


[ Reply to This | # ]
Great feature, a few supplements
Authored by: sabi on Aug 10, '12 09:53:03AM
You should just be able to add the search domain in Network System Preferences. scutil --dns should show you the resolver/search configuration; you could add it via scutil as well if you wanted to (the syntax is a bit annoying).

Note that you can actually have one machine with multiple iCloud accounts for Back to My Mac, so you may see multiple resolvers. For example, with two iCloud accounts configured, I see:

DNS configuration

resolver #1
  search domain[0] : nyc.sabi.net
  nameserver[0] : 8.8.4.4
  nameserver[1] : 8.8.8.8

resolver #2
  domain   : xxx.members.btmm.icloud.com
  options  : pdns
  timeout  : 5
  order    : 150000

resolver #3
  domain   : yyy.members.btmm.icloud.com
  options  : pdns
  timeout  : 5
  order    : 150200
[...]

This all worked with .Mac/MobileMe, too, except the domains were shorter and easier to remember («host».«username».members.mac.com); since iCloud uses arbitrary email addresses instead, I guess this is the best they could do.

If your SSH sessions are getting interrupted, check out mosh. I still use it with tmux for the multiple windows, but it's great on a flaky network or even just with a machine you're constantly putting to sleep. Unfortunately I think the license precludes an iOS port.

Edited on Aug 10, '12 09:54:52AM by sabi


[ Reply to This | # ]
Great feature, a few supplements
Authored by: CoolerQ on Aug 10, '12 12:43:28PM

As someone who has contributed to mosh, I can tell you that the license does not preclude an iOS port. However, it does have an open-source license, which means it cannot be incorporated into commercial SSH apps in the App Store. Anyone is free to take mosh and release an open-source app that uses it in the App Store.



[ Reply to This | # ]
Great feature, a few supplements
Authored by: rloomans on Aug 23, '12 10:27:35PM

There is specifically a waiver (https://github.com/keithw/mosh/blob/master/COPYING.iOS) that releases iOS developers from App Store related conflicts with GPLv3... but that not a free pass for commercial software to, for example, avoid the requirement to release source code.

I would be curious if this would mean that an existing iOS SSH client would be expected to release source to their entire app or just any changes they make to mosh...



[ Reply to This | # ]
Remotely connect to a Mac via SSH using iCloud's network
Authored by: pookacka on Aug 10, '12 09:25:34AM

My ISP's DNS server is unable to resolve the address with the above formula. I've double-checked that it should be correct, including checking the iCloud-reported computer name and member number. I don't think that's an IPv6 issue - any ideas?



[ Reply to This | # ]
Remotely connect to a Mac via SSH using iCloud's network
Authored by: cerberusss on Aug 13, '12 12:35:54AM

Same here; can't get it to resolve for some reason.



[ Reply to This | # ]
Remotely connect to a Mac via SSH using iCloud's network
Authored by: cerberusss on Aug 13, '12 12:58:58AM
I found out you can find the IPv6 address via: dns-sd -G v6 [machine-name].[accountnumber].members.btmm.icloud.com. Then you can copy/paste the IPv6 address and use it with ssh: ssh -6 2001:4860:4860:0000:8888 However, I still got an error message "operation timed out".

[ Reply to This | # ]
-6 really needed
Authored by: PatrickS on Aug 10, '12 02:39:39PM

Does this also work with IP4 or is IP6 required?



[ Reply to This | # ]