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.
Share
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
Hey Tim!
I remember you from the NeXT/usenet days!!
That is all.
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.
I mentioned that as a possibility (2nd paragraph). But it doesn't always work for me.
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.
"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.
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 Permalink rate up rate down ReplySmileyDude, 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 Permalink rate up rate down ReplyDeals of the Day
more deals- Cases for New iPad at HandHeldItems: Extra 20% off, $2 credit, from $3 + $3 s&h
- $15 Apple iTunes Gift Card for $8 for new Saveology customers
- Retro 80's Case for iPhone for $11 + $2 s&h
- HHI 360 Dual-View Stand Case for new iPad w/ $2 credit for $12 + $3 s&h
- HHI ReElegant Smart Cover Companion Case for new iPad from $5 + $3 s&h
- Used Apple iPad 64GB WiFi + 3G for $240 + free shipping
7 Comments