Tips, Tricks & Hacks for OS X

Earlier, I discussed how to control your torrents from a remote machine using Transmission, but for simply adding new torrents to Transmission, it turns out there’s an even simpler solution, using, yet again, Dropbox.  (I swear, they aren’t paying me!  I just really love this app!)

# 1.  Create a “watch folder” for new Torrents in Dropbox.

First create a folder where you’ll download new torrents you want added to your home server running Transmission.  I called mine, um, Torrents.

# 2. Setup Transmission to monitor your folder.

Open up Transmission and go to Preferences and select Transfers.  First, you want to make sure torrents are automatically added by checking “Start transfers when added” and either un-checking the “Display ‘adding transfer’ options window” or “Only when there are multiple files”, depending on if you still want this window to open up when you add files normally.

Now check the “Auto add” button and select the folder you created above.

As a side note, you should also ensure that the folder you are downloading these files *to* is outside of your Dropbox if you plan on downloading large files too big for your account.

# 3. Download a torrent to folder.

Download your (totally legitimage and wholly legal) torrent file to the Torrents folder of your Dropbox on another computer.

Voila!  Your torrent should now be downloading and ready for your enjoyment once you get home.  If you’re interested in checking on it’s progress while you’re away, check out my earlier post detailing that.

# 4. What if I already have Transmission monitoring a different folder?

So, I actually already have Transmission watching my Downloads folder so that things downloaded in a web browser automatically open as well.  Unfortunately Transmission only allows you to watch one folder at a time.  To get around this, I used the same trick I did in my iTunes/Dropbox watched folder tip.  I set up a launch daemon to watch my Torrents folder inside Dropbox and move any torrent files to the Downloads folder, where they’ll be picked up by Transmission.  You can download the script I made here.

If you’re on a mac, and you use bittorrent a lot, chances are you’re familiar with Transmission, a lovely little bittorrent client.  But did you also know you can control Transmission remotely from another computer?  (And it doesn’t even have to be a mac!)

# Setting up the server

Transmission has made this startling simple.  Just go into Preferences, and select Remote.  Check “Enable remote access”.  You should set up a username and login below if you have others on your local network you don’t want accessing your Transmission, or if you plan to access Transmission away from home (see below).  If the computer you’ll be accessing it from is a mac, you can turn on Bonjour for easy access.

# Accessing Transmission from another computer

Now on to the second computer, where you’ll be accessing Transmission from.  If it’s a mac and you have Bonjour bookmarks enabled in Safari, you should see a link for your Transmission remote.

If you’re second computer isn’t a mac, you’ll need to know the “.local” name for you remote machine — you can set this in System Preferences -> Sharing -> Computer Name -> Edit.  Now simply type that address into your favorite web browser appending the proper port number from above:

http://yourmachine.local:9091

Log in with the username and password you set up (if you set one up) and you should an interface very similar to the Transmission app!

From here, you can add torrents via URL or a torrent file you’ve already downloaded.  You can pause and resume torrents, control speed throttling and even see info on selected torrents.

# Setting up an app using Fluid or Prism

Want your Transmission remote to feel even more like an application?  You can use something called a Site Specific Browser (SSB) to create your own little app for that.

On OS X, I use Fluid, which uses the Webkit (Safari) rendering engine.

Download and install Fluid.  When you start fluid you’ll be prompted to create a site specific browser.  Copy and paste the URL from your browser (including the “/transmission/web/” into the URL.  Name it what you like and choose an Icon if you want (I just used the Transmission app’s icon, which happened to be installed on this computer as well).

Click create, launch now, and there you go.  You now have a Transmission Remote App.

If you’re using Windows or Linux, you can use the Prism app (which I mentioned in my post about accessing 1Password remotely) to set up a similar SSB.

# Access Transmission from your iPhone (or other mobile browser)

Transmission even has a nifty web interface just for the iPhone!  Simply navigate to the URL for the Transmission web interface from Safari and log in.

You can even create a psuedo iPhone app by adding a shortcut to the homescreen.

Now, I’m guessing the mobile interface would work on other mobile phones, but since I don’t have one, I can’t verify.

# Control Transmission away from home (Advanced)

This step is for optionally controlling Transmission while you’re away from home.  I actually find this to be particularly handy, if I’ve come across something I’d like to download while at work or away, but don’t want to run bittorrent on whatever network I’m currently on, and want the file to end up on the remote machine anyway.  This bit is a little more complicated, in order to proceed you’ll need:

  • (Unless you have a static IP) A dyndns account and dyndns updater installed on the remote machine.
  • Access to your firewall and router, and a knowledge of how to forward ports, and assign static IP’s within your NAT (assuming your device isn’t connected directly to the internet).

Setting up dyndns and port forwarding is a bit beyond the scope of this tip, so if you’re not familiar with how to do this, a little googling should point you in the right direction.

On your router, you’ll need to forward the Transmission web server port.  You can make the public port anything you like, but the internal port must match the number set in the Transmission Remote settings (the default is 9091).

While you’re away from home, you can use the dynamic host name you set up with dyndns to access your computer.  To try it out, type the address in the address bar as you did above, but replace the “.local” name with your dyndns host name.  If you made your public port something other than 9091, you’ll need to append that instead.

You can edit any bookmarks you made to the Transmission Web interface to use this new URL as well, but you’ll need to re-create your SSB’s and iPhone shortcut from scratch.

Now you can control your home Transmission from anywhere!

# Make sure it’s always running

One last note, the transmission app needs to be running for the web server to work, so if you just want to have it always running, right-click on the dock icon and select “Open at Login”.

There are a whole lotta ways you could access your mac at home while you’re away and control the desktop.  OS X comes with a VNC server built-in, and you could also use the fabulous LogMeIn.  But I’ve found, when it comes to user interface, my favorite screen-sharing client is actually iChat.  The credit for this idea goes to @lukebussey.

# What’s nice about iChat

The thing I really like about iChat’s screen sharing is the interface to switch between desktops.

You get a little “Picture in Picture” type of window of the other computer, while the remote one is full-screened.  Simply click the mini-window and it will flip the two.  I like this a lot, as having the remote screen full-screened makes it A LOT easier to control.  (Sure, the other options allow you to full-screen as well, but the switching back-and-forth is not nearly as smooth.)

Secondly, in my experience, the iChat client seems tuned for slower connections, and feels a lot more responsive than either the built-in screen sharing software or LogMeIn.  Sure, you can tweak these settings in those apps too, but this seems to just work better out-of-the-box.

Thirdly, if you’re using a mac a lot, you’ve probably got iChat open most of the time anyway.  So you don’t need to have another program open to control the remote screen, or even a browser window, as you do with LogMeIn.

# OK, I’m convinced, how do I set it up?

So obviously, you’ll need iChat running on the home machine you want to access, but in order to make this work you’ll also need to install the Chax plugin.  At the moment, if you’re running Snow Leopard, you’ll need the Chax beta available here, and make sure you start up iChat via the Chax app.

You’ll also need a separate IM account for the server, but you won’t want to give just anyone access to it, so I recommend setting up a new account on your IM network of choice.  This is pretty easy for AIM, but for GTalk you’ll need a whole new Gmail account.  Let’s use AIM as an example.

For added security, I made the username for my new AIM account a randomly generated string from 1Password, you can use whatever you like to generate passwords.  This way, only I know the username for my home machine’s AIM, so no one else can add it to their buddy list.  (I generated a password for it the same way.)

Set up the account on iChat on the home machine.  Set this account to automatically login when iChat opens.

Click Security.  Select “Allow people in my Buddy List”.  Add your personal account (and any other accounts you’d like to give access to) to the buddy list.

Now click the Chax settings.  Check “Auto-accept screen sharing requests”.  For even more security, select options to only accept requests from yourself.

Make sure that iChat/Chax starts up at login by right-clicking the Dock icon and selecting “Options -> Open at Login.”  Now, on the remote machine, fire up iChat and add the AIM user you created for your home server.

Right-click on this user and “Ask to share <user>’s screen”.

Done!

As a side note, you can also set up the account on the home server to auto-accept file transfers and specify a download folder in the Chax settings in the same way you set up screen sharing.

So, how great is Time Machine, right? You already know. If you’re like me, you back up all your Macs to an external hard drive or Time Capsule or some such. It’s certainly saved my butt more than once, and I can definitely sleep better at night knowing that years’ and years’ worth of mp3’s and pictures and everything else is backed up, safe and sound, in case of catastrophe. I’ve got most of my media on a Mac mini that’s always on at home, always being backed up. But work and other documents live on my Macbook, which is often not at home. So it’s great when I’m sitting on the couch, I just open it up, Time Machine start’s spinnin’ and blammo, backed up. Nice. Except…I’m not sitting on the couch at home as often as I’d like. So if I want to back something up while I’m away from home, or even retrieve an older version of a document, I’m up a creek until I get back to the homestead. Which is a shame, because that big ol’ hard drive with all my data is sitting at home, lonely, collecting dust.

# Step 1: Accessing the Time Machine disk remotely

First off, this obviously isn’t going to work unless your Time Machine is always on, either as a drive connected to another mac, or a Time Capsule disk on your Airport. Secondly, it’s probably not directly connected the internet, it’s likely sitting behind a router (unless it’s a Time Capsule, but even then, it’s not directly accessible to the outside world by default). Thirdly, you probably don’t have a static IP Address with which to access it. So the basic strategy for making the Time Machine Disk available is this: First forward the afp (the network file sharing protocol on macs) port on your router to the machine with Time Machine disk. You’ll need to forward port 548 to the machine with the Time Capsule disk. I’m not going to go into detail how to do this, as it will vary depending on your router, and there are plenty of excellent resources and tutorials out there on the Googles that would do a much better job of explaining it. Important exception! If you’re using a Time Capsule or your disk is connected to an Airport, you won’t actually need to forward the port, as they are directly connected to the internet anyway. However, you will have to open the ports up for access outside of your home. Open Airport Utility and click “Manual Setup”. Click on “Disks” and then “File Sharing”. Check “Share disks over WAN.” Also, I’d advise turning OFF Guest Access to the disks and using a very secure password to access them, as this disk is now exposed to the outside world.

Next you’re going to need an address to access this disk from if you don’t have a static IP address. (If you do have a static IP, you can skip this step, obviously.) There are plenty of services that will provide you with a domain name for your dynamic IP address, personally, I use DynDNS. It’s free and they’ve got a reliable OS X client. Note, if you’ve just got a Time Capsule, and not an always-on mac to run this, you’ll have to update it manually when you’re home. But honestly, your IP probably isn’t going to change all that much, likely only when you restart your cable or dsl modem. At any rate, register for a domain name and you should now be able to get to your router from the outside world via “yourdomain.dyndns.org”. To test out the domain and the port forwarding, while you’re away from home, open Finder, click “Go” —> “Connect to Server”. In the dialog box that pops up, type: afp://yourdomain.dyndns.org/

If everything worked, your Time Machine disk should now be mounted on your desktop!

# Step 2: Switching Time Machine Disks

Now, while the Time Machine disk is mounted remotely, open the Time Machine preferences and change the disk by choosing “Select Disk”.

You should see the share located at yourdomain.dyndns.org (or your static IP, or whatever). Select that.

That’s it! Now you’re backing up to the remote disk! You can also enter the Time Machine app and restore from previous backups, just like you were at home. When you’re back home, however, you’ll likely want to switch back to the “local” disk, as syncing of the LAN is preferable (more secure, faster) than syncing over the WAN. Plus it seems sort of silly to send your data outside your router, just to send it right back. So when you get back home, you can just open Time Machine preferences again and select the “local” drive.

# Step 3: (Optional) Switching between local and remote Time Machines automatically

Part of the thing that makes Time Machine so great is that it’s always backing up, every hour, without any input from me. It just works. So obviously, switching back and forth between local and remote disks would hinder this. At this point, I went a-googling for a shell script that would switch Time Machine disks for me, and I stumbled across this site, with a very helpful tip on how to do this. Basically, you will need to capture the encoded value for each drive, and then create one script for each disk, which you’ll trigger when you switch networks. To launch the scripts, I use a little program called MarcoPolo, which can perform any number of actions when you change networks, such as a launch a shell script. While you’re at home and the local disk is selected, open up Terminal and type the following:

defaults read /Library/Preferences/com.apple.TimeMachine BackupAlias

Now open up TextEdit and paste the following:

#!/bin/bash defaults write /Library/Preferences/com.apple.TimeMachine BackupAlias 'disk'

but replace “disk” with the results from Terminal. Save this file wherever you like to save your scripts, for example, ~/Library/Scripts/time_machine_local.sh. Repeat these steps for the remote disk and call it time_machine_remote.sh. In Terminal, navigate to the folder where you saved the scripts and make them executable:

chmod a+x time_machine_local.sh
chmod a+x time_machine_remote.sh

Next, to get these to run automatically, download and install MarcoPolo (if you are using Snow Leopard use this beta). Set up two contexts “Home” and “Automatic” (or whatever you wish to call them). Set “Automatic” to be your default context. Set up automatic context-switching (I prefer to do this by WiFi SSID.) Next, set up some actions to trigger on context change. Select new ShellScriptAction and create one to trigger time_machine_local.sh when you arrive at the “Home” context. When you depart, trigger time_machine_remote.sh.

# Final Thoughts on Security

Is this secure? Well, no, not really. It’s password protected, but your backup disk is now open to the internet, and additionally, the transfers are not encrypted. If this is a concern for you, there are a couple things you could try (but I haven’t tried personally):

  • Set up a VPN at home (iVPN is one solution) instead of opening up the afp port and connect that way.
  • Set up an SSH server at home and tunnel the afp port through that.
  • ShareTool sets up a VPN over SSH and supports Bonjour.
  • ??? Do you have any better ideas? Let me know!