Is it possible to use Back To My Mac DNS or routing information from the command line? I often want to ssh to a Mac and would love to make use of of iCloud to look up IP/DNS routing information. Can this be done without signing up for a dynamic DNS service and configuring it on each Mac in addition to iCloud?

Let's assume of my on-all-the-time Mac at home's hostname is "maui" and it's running Snow Leopard. When I'm on my laptop connected to the home network, I can ssh maui.local. It sure would be nice to be able to ssh maui.whatever.icloud.com or whatever would work. I'm guessing I would need "maui" and my iCloud name to let it know which machine under my account needs reaching.

Does anyone know if this is possible through API or command line? I've browsed the public developer information several times but don't see anything promising. Any pointers or code examples would be welcome.

P.S. Please don't suggest free DNS accounts as I'm really interested in MobileMe exclusively for this question. I know those will work but I'm looking to avoid installing anything else or another account/external dependency on these Macs.
This has changed a little with 10.7 and you'll want to note that this uses IPv6 almost entirely so test with ping6 and traceroute6 to debug things.

It's no longer done via @computername.mobilemename.members.mac.com, it's now done via members.btmm.icloud.com, and its no longer as simple as your mobilemename.

Step 1: Find out your iCloud BTMM domain

Either of these commands will provide your BTMM domain:

# dns-sd -E
# mDNS -E


The output is formatted slightly differently, but what you're after is the numeric ID, it'll be something like 12345678.members.btmm.icloud.com.

Step 2: List Computers

You can use these tools to browse that domain for services, e.g. for ssh servers:

# dns-sd -B _ssh 12345678.members.btmm.icloud.com


Or if you already know the hostname just access it directly as computer-name.12345678.members.btmm.icloud.com. (Any spaces in your computer name will be hyphens in this domain).

You can only access this from a computer that is also set up for BTMM on the same account, because this hostname will resolve to an IPv6 address that is really the end of an encrypted network tunnel between your BTMM computers.

If you want to see the IPv6 address for a specific host, you can type

# dns-sd -G v6 computer-name.12345678.members.btmm.icloud.com


And it'll output something like:

17:37:47.504  Add     2  0 computer-name.12345678.members.btmm.icloud.com. FD11:993E:64AE:4DEA:011F:FBD1:F444:11A1%&lt;0&gt;  152


Step 3: Connect

# ssh username@computer-name.12345678.members.btmm.icloud.com


Note

I'm not sure if that number will ever change, so you may or may not need to repeat Step 1 at some point later on...