User loginSearch |
Public Key Authentication in WindowsSo you've read my blog entry on Why Enter Passwords? and it changed your life. In linux. So like 95% of your life is now covered. But you have that windows machine you need to do some work on for whatever reason, and you don't want to enter your password a bazillion times to do ssh+svn on that, either. Let me break down the specific scenario, and be careful to define the scope of my solution. * I have a Windows XP client on which I do work. Background info: * Subversion rocks. If you want to keep track of changes to files and be able to sync changes and version over multiple computers and/or with multiple people, check it out. http://subversion.tigris.org/ The Problem: There's no easy way to install a public key on the server, which would allow you to use password-free authentication. The Scope: This solution is based on PuTTY. If you use Putty (http://www.chiark.greenend.org.uk/~sgtatham/putty/) for your general SSH'ing, this solution will work for that. If you use winSCP (http://winscp.net) for file transfers with a linux machine, this solution will work for that. It's not just about SVN, it's about the SSH layer, which happens to be powered in this case by the Putty family. The Solution: The key is PuttyGen. Go to the Putty page and download this separate program. All this program does generate key pairs. It doesn't magically install them, because windows doesn't really have a place to "install" personal RSA keys like linux does. You can save them as files, and that's good enough for my purposes today. Open up PuttyGen, select SSH2-RSA at the bottom, and hit the generate button. It'll do some magic and create a keypair. Save them as files somewhere that makes sense to you, and name them something that makes sense. Remember, the difference between the Public and Private keys is VERY IMPORTANT. If you switch the keys, stuff doesn't work. The math only works in one direction (that's actually what makes it secure, actually. Read more: http://en.wikipedia.org/wiki/Public-key_cryptography). So you have your key files. Now we need to install the public key to the server and set up your local system to use the private key. Let's start with the server. All you need to do is edit a file on the server in your home directory: Add a new line on the bottom that starts with "ssh-rsa" has one space, then has your entire public key on one line. If you copy and paste in from the public key file you made earlier, just copy in the bulk part and delete the line returns. The key doesn't actually depend on the line returns, it just formats it that way in the file so it's easier to read. FYI: this method can be used in linux as well if you don't want to use the automatic ssh-copy-id program. So now the key is installed on the server. Time to set up the client to use it. Open PuTTY. We're going to set up a session with the key and save it. Now when you want to log in with putty, just double-click that saved session and it'll go right in. Enter your username and no password will be needed. If you want to use WinSCP with the key, you basically do the same thing, except the Private Key file field is right on the front page. Now back to tortoise. Check out something for the first time by right-clicking in a folder and selecting "SVN checkout." That's it! It won't ever ask for a password! Caveats: Happy geeking! Reference material: http://tortoisesvn.net/node/5
|