TextMate News

Anything vaguely related to TextMate and macOS.

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/id_dsa.pub) 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 ceo@macromates.com with your user and server name (by default the user name is your local user):

scp ~/.ssh/id_dsa.pub ceo@macromates.com:

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

ssh ceo@macromates.com
mkdir .ssh # if it's not already there
cat id_dsa.pub >>.ssh/authorized_keys
rm id_dsa.pub # 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
HostName macromates.com
User ceo

This defines a new host (named mm) which expands to macromates.com 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

Or

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.

categories General OS X Tips

34 Comments

Don’t forget about the IBM keychain bash script:

http://www.gentoo.org/proj/en/keychain/

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

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.

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.

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.

07 November 2005

by Sander Cox

For caching of SSH keys I use the SSHKeyChain http://www.sshkeychain.org/

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.

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

10 November 2005

by iznogoud

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

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

10 November 2005

by iznogoud

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:)

12 November 2005

by Greg Humphreys

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

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 /
Advanced)

Locations searched:

/Library/Application Support/TextMate/Support/bin/CocoaDialog.app/Contents/MacOS
/bin
/sbin
/usr/bin
/usr/sbin
/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.

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

@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.

03 February 2006

by Ola Leifler

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

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.

18 February 2006

by dreamscape

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.

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

scp ~/.ssh/id_dsa.pub alaskamike@macromates.com:

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

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

06 July 2006

by Louis Theran

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.

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

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).

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

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…

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/id_dsa.pub ssh you@example.com “cat - >> ~/.ssh/authorized_keys”

21 November 2007

by diyafury

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?

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 :)

21 November 2007

by diyafury

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

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?

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

This line gave me a problem - file not found

cat id_dsa.pub >>.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/id_dsa.pub >>.ssh/authorized_keysor there should be acd .sshcommand

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.

Hi,

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 ¿?.

Thanx

loncho: the best svn tutorial is at http://svnbook.red-bean.com/

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

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 :)

http://ciaranwal.sh/projectplus