Speed Up Mac Web Development with iTerm
Posted On: October 29, 2010 at 9:38 p.m.
I’ve been playing around with Panic’s Coda for use as an editor and overall I still prefer Textmate as my editor. But one thing I did find I loved about Coda was the way sites were saved and an SSH connection could be saved along with a project. This meant that I could update a website, commit my changes to SVN (yes I’m lame and haven’t yet switched fully to a DVCS) and then click on the terminal tab in Coda, have it log me in automatically without a password since that is saved in Coda as well and - if you’ve put in a remote directory for the project - have it change to that directory. I could then just to a “svn up” and be done. No trying to remember which server the site is on, what directory its stored in… Simple and fast! Its not going to save me hours but every minute counts.
So, how can I get the benefits of quick SSH logins tied to a project and still keep my Textmate? What I needed was a way to “bookmark” an SSH connection and run it the same way each time, but how? I found lots of different ways to be able to do just that, from adding them to a bash script to using Applescript but none of them felt right. Then I stumbled on iTerm, a replacement shell for Mac. It seemed perfect, since it had just what I wanted, a way to bookmark a connection.
So I installed it and all seemed fine, but I’ve really grown accustomed to a light on dark custom color scheme that I created for Terminal. A quick look around pointed me right to the solution though. A pastel color scheme for iTerm that is very close to what I’m used to.
With that out of the way it was just a matter of making the connection correctly. When I add a bookmark in iTerm I simply name it and then put something the following in the Command area:
ssh -t user@server_or_ip "cd ~/server/path/to/website/files ; bash"
It would log me in (still requesting a password) and cd into the server directory. Perfect!
But now to get rid of the annoyance of still having to type in my password every time. Its pretty easy using SSH key pairs. Here is what I had to do to get it working for me.
First generate the local key on your Mac (or Linux box):
- Open terminal or iTerm
- Create a ~/.ssh folder if there isn’t one already by entering mkdir -p $HOME/.ssh
- cd ~/.ssh
- ssh-keygen -t dsa
- Press enter at each prompt to accept the default.
Now add the new key to the server:
scp ~/.ssh/id_dsa.pub username@domain.com:temp_dsa_key.pub
Open an SSH session to the server and do the following:
- If its not already there add a ~/.ssh folder, mkdir -p $HOME/.ssh
- Add your key to the authorized_keys file by entering cat ~/temp_dsa_key.pub >> ~/.ssh/authorized_keys
- Remove that temp file, rm temp_dsa_key.pub
- Secure those keys, chmod 600 ~/.ssh/authorized_keys
- Secure the directory, chmod 700 ~/.ssh
Tada! We have liftoff. Now I simply open iTerm, click on my book mark for a site and kablammo!
Let me know what you think in the comments below.
PS. I saw there was a Textmate iTerm bundle but I’m not sure how that helps me yet. Perhaps I could open iTerm directly from a project in Textmate???


Neum Oct. 29, 2010 at 10:40 p.m.
If I can see this then my comments work just dandy!