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.
Two things it currently doesn’t do is:
- Indicate the status of a file. I plan to add the proper API so that plug-ins can provide this.
- 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.