Subversion support and ssh key pairs

From time to time a user asks for Subversion support in TextMate, and recently I saw a comment on the Rails blog asking for it as well.

So just a note to mention that TextMate already has pretty good out-of-the-box Subversion support, and a short tutorial about how to generate ssh key pairs to avoid having to type passwords when you login over ssh.

You’ll need to checkout your files from the terminal, but after that you can press ⌃⇧A to get the following menu (with Subversion actions) for the current file, or in case of Add to Repository and Commit, actions for the selected items in the project drawer.

subversion menu

Two things it currently doesn’t do is:

  1. Indicate the status of a file. I plan to add the proper API so that plug-ins can provide this.
  2. Request password if you use subversion over ssh. The solution to this is to generate an ssh key pair and upload the public key to the server, so that you can connect to the server w/o having to enter password.

To generate an ssh key pair you’ll need to run the following line in your terminal:

ssh-keygen -t dsa

It’ll ask for location and pass phrase, and you should accept the default location (~/.ssh/ and press return when it asks for pass phrase (to give the private key a blank pass phrase).

After this you need to upload the public key to the server. For this we use scp. Substitute with your user and server name (by default the user name is your local user):

scp ~/.ssh/

Finally login to the server and append the public key to authorized keys:

mkdir .ssh # if it's not already there
cat >>.ssh/authorized_keys
rm # cleanup

After this, you should be able to login to the server and use scp without having to enter a password.

If you do login or copy files to your server a lot, you can setup an alias. This is done by editing ~/.ssh/config (on your local machine). For example I have this entry in that file:

Host mm
User ceo

This defines a new host (named mm) which expands to and with ceo as the default user. What this allows me to do is copy files like this:

scp some_image.png mm:www/images


ssh mm ls www/images

The first example copies some_image.png from my local folder to the www/images folder on the server. The second example logs into the server, executes an ls www/images, and gives me back the result.

For more info about the ssh configuration file run man ssh_config.

And just for the records, my user isn’t named ceo, I made that up to avoid my real user (i.e. email address) to be harvested.


  1. 06 November 2005 | # Ben Jackson wrote…

    Don’t forget about the IBM keychain bash script:

    Super-useful in case it irritates you having to type in your keychain password every time you open a terminal.

  2. 06 November 2005 | # Bob Aman wrote…

    Well, it’s awesome to see that those options are there, but I was thinking of something more visual, like different background colors to indicate whether the file had been changed, etc in the file browser panel. Like, if the file is out of sync, the file’s row has its background color set to light red, and if it’s up to date, it’s colored light green. Nothing overly obtrusive – more just a gentle reminder that you’re looking at files that are under source control, and so that you can see their current status at a glance.

  3. 06 November 2005 | # Mr eel wrote…

    I think Bob’s idea is an excellent one. It’s not such an issue for me at the moment since I am generally the only person working out SVN repository, but in a multi-dev environment it would be a really useful feature. A gentle reminder check in changes frequently.

  4. 06 November 2005 | # Allan Odgaard wrote…

    Bob, Mr eel: this is what I was addressing with item 1. The API is not there to allow it yet, so it needs to be added first, as svn support is not built into TextMate, but added through a bundle, like is also done for Darcs, SVK, Perforce etc.

    For now there’s ⌃⇧A + S + return to see the status of the files in a project.

  5. 07 November 2005 | # Sander Cox wrote…

    For caching of SSH keys I use the SSHKeyChain

    It work’s flawless for me for a long period allready, and it can lock your keys when you put your system to sleep, very usefull with laptops.

  6. 09 November 2005 | # Mischa wrote…

    Hm, interesting. How about CVS is that hidden somewhere too??

  7. 10 November 2005 | # iznogoud wrote…

    Just a stupid question. I don’t know if making ^⇧A is easy on qwerty keyboards, but on a french one, it just makes me do a

  8. 10 November 2005 | # Allan Odgaard wrote…

    iznogoud: the ⌃ glyph is the control modifier key.

    The subversion stuff is accessible with the mouse either clicking the gear icon in the status bar and locating Subversion or from the menu: Automation → Run Command… → Subversion

  9. 10 November 2005 | # iznogoud wrote…

    wouhou, that’s great :) I tried almost all combinations but didn’t try the ctrl key.

    that opens me quite a lot of perspectives… Thanks for that incredible text editor, since I tried it, I can’t go back to my previous ones (emacs and subethaedit).

    I’ll make a new suggestion on the wiki, I have a new idea:)

  10. 12 November 2005 | # Greg Humphreys wrote…

    Also it would be awesome if the SVN support worked with servers that use Apache 2.0 authentication as well as ssh.

  11. 12 November 2005 | # David wrote…

    I have Subversion installed via Fink, i.e. at /sw/bin.

    When I run the svn bundle commands, I get this error:

    Couldn't find svn
    If you have installed svn, then you need to either update your
    PATH or set the TM_SVN shell variable (e.g. in Preferences /
    Locations searched:
    /Library/Application Support/TextMate/Support/bin/
    /Library/Application Support/TextMate/Support/bin

    How do I add /sw/bin to the path that TextMate searches? I don’t want to have to set the TM_SVN variable and then repeat for all the other things that I have installed through fink.

  12. 12 November 2005 | # Allan Odgaard wrote…

    Put this in your ~/.bash_profile (create it, if it doesn’t exist):export PATH="$PATH:/sw/bin"

  13. 13 November 2005 | # Tim Lucas wrote…

    @Greg Humphreys: just make sure you have used SVN with that repo before (for example, by doing a checkout in terminal), as SVN caches the user/pass. If it’s in SVN’s cache it’ll work fandoodly.

  14. 03 February 2006 | # Ola Leifler wrote…

    Shorter version of uploading public key:ssh user@host 'cat >> .ssh/authorized_keys' < .ssh/

  15. 16 February 2006 | # jpb wrote…

    If colorized file names are going to be added, I’d like to see red for files that aren’t under subversion control in a directory that has subversion controlled files, yellow for files that haven’t been checked in, and green for files that haven’t been modified.

  16. 18 February 2006 | # dreamscape wrote…

    Not sure why there is no delete command in the Subversion bundle.

    I’ve just duplicated the “Add to Repository”, renamed it to “Delete from Repository”, and in the command changed “add” to “delete” and it seems to work fine, so I’m really not sure it isn’t included in the default SVN bundle… Unless you think people are just going to mad and bounce around deleting all their files, but c’mon people aren’t that dumb.

  17. 26 May 2006 | # Alaskamike wrote…

    I’m a little confused about copying my key to the server. Should I use:

    scp ~/.ssh/

    and my subversion password? I am getting a “Permission denied (publickey,password).” error.

  18. 26 May 2006 | # Allan Odgaard wrote…

    You do not have any ssh account @ — if you are thinking about the bundles repository, thus runs over webdav, not ssh.

  19. 06 July 2006 | # Louis Theran wrote…

    There is a reference in

    07 Nov 2005 # Allan Odgaard wrote…

    to support for darcs, but it doesn’t seem to be part of the default installation, and a google search doesn’t turn anything up. Can somebody give me a pointer for TextMate darcs support? Thanks.

  20. 06 July 2006 | # Allan Odgaard wrote…

    Louis: It’s at the bundles repository. See Getting More Bundles for detailed instructions.

  21. 01 August 2006 | # Greg wrote…

    Any word on when the plug-in API mentioned in this article will be done?I agree with Bob’s comment that color-coding would be very useful (or even just status characters off to the side like you see in Xcode).

  22. 02 August 2007 | # Jad wrote…

    Alaksamike, use ssh-copy-id -i ~/.ssh/ user@host to copy your key.

  23. 20 October 2007 | # StuFF mc wrote…

    Insisting on Greg’s comment from Aug. 2006, I was wondering if you plan a “easier/better” subversion support, something like “Versions” is about to bring, but directly in TextMate…

  24. 24 October 2007 | # Rich Bodo wrote…

    Thanks guys! Got it working using keychain.

    To install keychain:

    fink install keychain

    Add to ~/.bash_login:

    keychain ~/.ssh/id_rsa ~/.ssh/id_dsa . ~/.keychain/uname -a | awk {'print \$2'}-sh

    You should never have to fiddle with logins again.

    For those of you who happen to read this obscure post at the bottom of the thread, and who are looking for the one-liner to add your key to a server, you are in luck:

    $ mkdir ~/.ssh/ $ cd ~/.ssh/ $ ssh-keygen -t dsa $ cat ~/.ssh/ ssh “cat - >> ~/.ssh/authorized_keys”
  25. 21 November 2007 | # diyafury wrote…

    Just a note:

    I had to set the read/write permissions on my authorized_keys file before this worked for me:

    $ chmod 700 ~/.ssh $ chmod 600 ~/.ssh/authorized_keys

    also, I’m a TextMate novice (have been using jEdit which has sftp support - textMate doesn’t have this right?) anyway, I’m trying to checkout a remote svn project via the subversion bundle menu – svn+ssh://blah-diblah and I still get a permission denied error, my key pair has been setup and works fine from the terminal… Your post mentions something about having to checkout projects from the terminal, does this mean the menu checkout is still to be implemented or am I missing something?

  26. 21 November 2007 | # Allan Odgaard wrote…

    diyafury: as for authorized_keys, it needs to be so that other users cannot write to this file (or write to the .ssh directory so they can effectively replace it) since then other people can then add their public key. But it is fine that the file is world-readable (afaik).

    As for checking out repositories from TextMate, there is a checkout command, but to be honest, it has seen close to zero testing from me (though I wasn’t the one to add this command). A checkout is something you do once for a project and then never again. I did try it once or twice, and it worked, but if it doesn’t work, well, just go to Terminal and do the checkout :)

  27. 21 November 2007 | # diyafury wrote…

    coolio, cheers. A checkout from the terminal it is then :)

  28. 10 January 2008 | # Steve wrote…

    When I try to do a commit from the subversion popup page, the spinning dial starts up and never stops. After waiting a while, I killed the svn process at the command line. Once I did that, TM poped up a window asking for my SVN password.

    I have used svn at the command line for months to check in/out code and it works perfectly. My username on the svn repository is different from my username on my mac, but the first time I used svn from the command line, it failed and then I was able to put in the correct username and password. Since then (months ago), svn from the command line has worked perfectly. I think when svn is started by TM it must be using my mac user name rather than the cached name. Is there any way I can control this?

  29. 16 January 2008 | # Steve wrote…

    Also, I forgot to mention that after I type my comments and hit commit, in the status window the following appears:

    Authentication realm: PAC

    but I can’t see any place that I can type to supply my credentials

  30. 03 August 2008 | # decibel.places wrote…

    This line gave me a problem - file not found

    cat >>.ssh/authorized_keys

    The previous command ssh-keygen -t dsacreates the key in the .ssh directory (with the defaults) somkdir .ssh # if it's not already thereis unnecessary and the next line should becat .ssh/ >>.ssh/authorized_keysor there should be acd .sshcommand

  31. 01 October 2008 | # Bill G wrote…

    I am new to TextMate. Is it possible to use the Subversion bundle with a remote server using WebDAV? I have been searching and have found no references on how to make it work. Thank you.

  32. 12 November 2008 | # loncho wrote…


    On a new project the team ask me if I can work with SVN using textmate, I was using textmate for editing code and conect ftp with cyberduck. But I not have any clue of how I have to conect textamate to a svn repository that the team sendme.

    There is a tutorial o some guidelines for a dummies ¿?.


  33. 04 December 2008 | # Abhi Beckert wrote…

    loncho: the best svn tutorial is at

    you don’t have to read the whole thing, just the first few sections should teach you everything you need to know.

  34. 19 August 2009 | # Ben wrote…

    Ciaran Walsh’s Project Plus plugin has support for status highlighting in many different version control systems. Very nice addition to the already awesome TM SVN support :)