Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

I often want to ssh to a Mac and would love to make use of of MobileMe to look up IP/DNS routing information.

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.connectivity.me.com or whatever would work in place of connectivity.me.com (I've also tried members.me.com to no avail). I'm guessing I would need "maui" and my mobile me 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.

When I turn off and then on Back To My Mac - messages in system.log make me think mDNSresponder or racoon might be the entry points to get this functionality.

May 12 22:36:43 maui awacsd[72445]: Connecting AWACS client: bmike hello.connectivity.me.com
May 12 22:36:51 maui mDNSResponder[19]: Adding registration domain bmike.members.mac.com.

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'd rather hack/extend use this if at all possible.

share|improve this question
    
Cool idea, +1 and I hope you get an answer. –  hobs May 13 '11 at 13:52
    
I can see how Apple wouldn't want to expose users to this since it's a privacy risk, but it sure would be cool to have an API for this. –  bmike May 13 '11 at 16:42
1  
See also: The same issue for OS X 10.7 Lion (it's a bit different). apple.stackexchange.com/questions/53719/… –  drfrogsplat Jun 15 '12 at 5:29
add comment

5 Answers 5

up vote 2 down vote accepted

You can ssh to your machine which has "Bac to my Mac" enabled like this:

ssh -p 22 username@computername.mobilemename.members.mac.com
share|improve this answer
    
Do you really have to tell it to use the default port? –  hobs May 13 '11 at 20:40
    
ping, host and ssh to three separate computername with three different mobilemename is failing. I get host yy.xx.members.mac.com not found: 3(NXDOMAIN) errors from host attempts and ssh: Could not resolve hostname yy.xx.members.mac.com: nodename nor servname provided, or not known All three work with back to my mac screen sharing before and after the ping, host and ssh attempts fail. What DNS server IP are you using to get this to work? –  bmike May 13 '11 at 20:50
    
Even though host and ping don't work - ssh started working for me. I'll play a bit and mark an answer once I figure which is better. –  bmike May 13 '11 at 21:06
    
And no - I don't seem to need to call out port numbers for sftp or ssh - but it doesn't hurt much to have them ;-) –  bmike May 13 '11 at 21:44
    
host doesn't work because it's using the DNS resolver, not the system resolver. ping doesn't work because BTTM uses IPv6. Try ping6 instead and you'll see it responds. –  bahamat Jun 14 '12 at 22:41
add comment

This has changed a little with 10.7.

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%<0>  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...

share|improve this answer
    
Brilliant! I'm undecided whether to edit the question to fit Lion or ask another. I'll link to the new question so you can "answer" the Lion question - this answer is so useful. –  bmike Jun 14 '12 at 16:27
    
Here it is! apple.stackexchange.com/questions/14049/… –  bmike Jun 14 '12 at 16:38
add comment

I read a few articles on the underpinning of Back To My Mac and supposedly some people have effectively connected via ssh, check out the discussion contained in this Macworld post.

The best post in the thread is as follows:

Use the following format for connecting as a differnent username:

ssh user.name@hostname.username.members.mac.com.

If you do this regularly and wish to save having to use the username all the time for ssh and scp then create a file called ~/.ssh/config with contents like the following:

Host hostname.username.members.mac.com. User user.name

Host host2.some.domain.com. User username2 Port 2222 LocalForward 3389 internal-pc:3389

The second host in this file also includes using a port other than 22 and allowing access to a Windows computer called internal-pc with Remote Desktop by connecting to localhost with the Remote Desktop Client.

Now obviously Apple has switched .mac to MobileMe, so I dont know if that has switched to .me.com, and frankly I dont have a MobileMe account to test it.

Edit: Another interesting post you may want to try is at the veery bottom

Turns out it is even easier! :P

just open the Terminal go to Shell > New Remote Connection...

then choose ssh and there you have your BackToMyMac Computer listed (if the OS sees it).

type in your username and click connect.

voila, you can even see the connection string used. And you can also use ftp/sftp... from this dialog to your remote Mac.

Way easier than typing in some shell command like suggested in the original tip.

share|improve this answer
    
Sadly this isn't working for me. I can use finder and screen sharing perfectly so I know the accounts and machines are up and running. Recent Time Capsules with up to date firmware are routers for both macs. Has anyone had this work for them in the last two weeks? –  bmike May 13 '11 at 21:00
    
Hot dang! the last tip was it. ping and host don't work, but ssh does. That terminal tip is AWESOME. –  bmike May 13 '11 at 21:05
    
Sweet! Glad to help. –  hobs May 13 '11 at 23:17
add comment

That's because the IP addresses for resolution are version 6.

If you use ping6 or traceroute6 you can reach your host as well.

share|improve this answer
    
That is really cool. Thanks so much for adding this. Do you mind if I add your info to my answer above once I have a chance to see if it works for me? +2 to @pst –  bmike Jun 8 '11 at 21:21
add comment

Big thanks to hobs and ghoppe who both had workable solutions. The main problem is that MobileMe Back To My Mac uses IPv6 addressing if available and perhaps exclusively, so I didn't think to use ping6 or traceroute6 and ssh is apparently smart enough to resolve either IPv4 or IPv6.

ssh -p 22 username@computername.mobilemename.members.mac.com. works very reliably for me in testing today.

Since this tripped me up as I was expecting ping and host and nslookup to work, I figure I'll put up a nice summary of what worked for me. (with pictures! - I really like pictures)

To summarize sftp, ssh, ping6, and traceroute6 should work with this naming scheme.

Apple's built in terminal (and iTerm) is great to make sure your user name and remote short name are correct. The name is the short host name (what hostname prints out) and not necessarily the longer sharing name Finder will show for the remote Mac).

short hostname

Here is what the Terminal shows when it discovers Back To My Mac machines running. The menu item is New Remote Connection... and the shortcut is Shift+Command+K. It shows how the finder name "Mikey's Mac" might be different than the short host name mi

enter image description here

share|improve this answer
1  
Good comprehensive answer with screenies +1 –  hobs May 13 '11 at 23:23
    
hobs has one b :p –  hobs May 14 '11 at 2:29
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.