Skip to Content

Terminal Tips: More reliable SSH connections to your Back to My Mac hosts

Back to My Mac is a feature of MobileMe that allows you to connect remotely to your Macs. Usually this is for screen-sharing or file-sharing through the Finder, but you can also connect via SSH.

In the Terminal app (found in /Applications/Utilities/), you can connect via Shell » New Remote Connection, then click the "Secure Shell (SSH)" item, then the computer you want to connect to under the "Server" column.

But what if that doesn't work? In that case, I have two suggestions for you: first, use SSH v2 and IPv6. Perhaps it's best to show you the command and then explain it:

ssh -2 -6 imac.luomat.members.mac.com -v

The "members.mac.com" is consistent for all users. "luomat" is my MobileMe username. "imac" is the hostname of my Mac. See System Preferences » Sharing if you don't know what your computer's name is, or to change it.

The "-2" tells SSH to only try SSH protocol version 2, and the "-6" tells SSH to only use IPv6 addresses. The "-v" tells SSH to be "a little" verbose in its output. That part is optional. You could also use -vv or -vvv if you want more verbosity.

So far, this method has given me even more success than my DynDNS hostname, which I described before. Before you worry about the security implications of giving people my MobileMe hostname, I should mention that it seems to be impossible to connect to BTMM hostnames unless you are connecting from another computer that is logged into that same MobileMe account.

If you have spaces in the computer's name, they are usually replaced with "-" and punctuation is ignored. So, "John's iMac" becomes "Johns-iMac" in the SSH command. Marco Arment also figured out that if you have a period in the hostname or MobileMe username, you should escape it with a \ so that "john.doe" becomes "john\.doe" when you are connecting via SSH.

Of course, to be able to connect to your remote Mac via SSH, you must have enabled "Remote Login" under System Preferences » Sharing.



Categories

How-tos Mac MobileMe

Back to My Mac is a feature of MobileMe that allows you to connect remotely to your Macs. Usually this is for screen-sharing or...
 

Add a Comment

*0 / 3000 Character Maximum Comment Moderation Enabled. Your comment will appear after it is cleared by an editor.

7 Comments

Filter by:
EricSeale

Hey Tim!

I remember you from the NeXT/usenet days!!

That is all.

November 10 2010 at 3:11 PM Report abuse rate up rate down Reply
Brian Allen

I just use the built-in feature of Terminal to connect to my computers.

Select "New Remote Connection…" or type ⇧⌘K
Select "Secure Shell (ssh)" from Service area.
All available computer will be listed on the right.
Select computer and then click "Connect".

This works every time a Mac.

November 10 2010 at 11:37 AM Report abuse +1 rate up rate down Reply
1 reply to Brian Allen's comment
TJ Luoma


I mentioned that as a possibility (2nd paragraph). But it doesn't always work for me.

November 10 2010 at 12:03 PM Report abuse rate up rate down Reply
SmileyDude

Every time I use Back to my Mac and ssh, it always defaults to protocol 2 and IPv6 -- so I'm not really sure if forcing those will make a difference.

However, there is a little trick that makes using ssh with Back to my Mac a little nicer -- you can configure an alias for ssh by creating a file called config in your ~/.ssh directory. In there, you can put an alias by adding the following lines (using the address in the article here):

Host imac
HostName imac.luomat.members.mac.com

By doing this, you can simply ssh to imac instead of the full name. It also works with any tools that use ssh as their underlying protocol, including scp, rsync, hg and git.

Combine this with public key authentication, and you have a quick and easy way to get back to your Mac from the command line.

November 10 2010 at 11:17 AM Report abuse rate up rate down Reply
Rafe H.

"it seems to be impossible to connect to BTMM hostnames unless you are connecting from another computer that is logged into that same MobileMe account."

I wonder if MobileMe + Putty on Windows works? I will try when I get to work. Excellent tip.

November 10 2010 at 11:15 AM Report abuse rate up rate down Reply
2 replies to Rafe H.'s comment
SmileyDude

To ssh to a machine using Back to my Mac, both machines need to be authenticated with MobileMe. Since Apple does support Windows for MobileMe, it might be possible that you can use the mac.com address, but since Back to my Mac is a Mac only feature, you might be out of luck.

November 10 2010 at 11:18 AM Report abuse rate up rate down Reply
Rafe H.

SmileyDude, what exactly do you mean by "authenticated with MobileMe"? I have the MobileMe control panel installed in Windows at my work.

November 10 2010 at 12:31 PM Report abuse rate up rate down Reply
Buy an ad here

Tweets

© 2012 AOL Inc. All Rights Reserved.