I’m : a programmer, writer, podcaster, geek, and coffee enthusiast.

Back To My Mac hostnames with dots in your username

If you have MobileMe, you can access your Back To My Mac-enabled computers via SFTP and SSH (if enabled in Sharing) with this hostname:

…where computer is the hostname and username is your MobileMe username (before the “@”).

But if your hostname or username contains a dot or other special character that isn’t normally permitted in DNS, it becomes tricky. You can see how the hostname is encoded by opening Terminal and selecting FileNew Remote Connection…, then Secure File Transfer (sftp), then the target hostname under Server, and see how it encodes it on the command line in the bottom text field.1

If your MobileMe username was and your computer was called John's iMac, it would show this:

sftp -oPort=22 Johns-iMac.john\

The backslash isn’t a valid DNS character. Leaving it in, double-escaping it, omitting it, or replacing with a literal period all don’t work for most common commands like ssh, ping, or dig.

Because it’s actually an IPv6 address.

Disclaimer: I know absolutely nothing about IPv6.

So it actually does work with IPv6-enabled commands:

ssh -6 'Johns-iMac.john\'
ping6 'Johns-iMac.john\'

If you enable Remote Login (SSH) and set up the SSH connection with password-less keys, you can get your computer’s external IP and avoid the need for DDNS for certain uses (like many of mine).

HOME_IP=`ssh -6 'Johns-iMac.john\' \
    curl -s ''`

I’ll be shocked if more than zero people who see this can actually use this information, but it has been eluding me for months and I finally figured it out.

  1. Thanks to Cabel Sasser for this tip. His company just released Transmit 4, a ridiculously good file-transfer client. ↩︎