is outdated. I moved my blog over to See you there.

Windows, svn+ssh and the Subversion command line client

This morning, I needed to access an svn+ssh Subversion repository from a Windows box. Since I am a command line aficionado, I decided to do it using the Subversion command line client. It turned out to be quite more complicated than I thought… So here is how I did it :

Download plink.exe and puttygen.exe from Putty website.

Next step is to generate an SSH key and place it on your server.

  • Start puttygen and generate a private key.
  • Save it.
  • In the upper part of the window, there is a text field labeled “Public key for pasting into OpenSSH authorized_keys file:”. Log on your server and append the content of this text field to the $HOME/.ssh/authorized_keys file (create it if it does not exist).
    The content of this text field is different from what you would get with the “Save public key” button. Do not try to copy this generated public key. It won’t work.
  • Check if it works: try to login on the server with plink:
    plink -i c:pathtoyourkey.ppk user@server

    If everything goes well, you should get logged in without getting asked for your password.

Now you need to configure Subversion to use plink for “svn+ssh” uri.

  • Edit the file c:\Documents and Settings\user\Application Data\Subversion\config
  • Locate the section named [tunnels]
  • Add the following line :
    ssh=c:/path/to/plink.exe -i c:/path/to/your/key.ppk

You are done, it should work now. Let’s give a try:

svn co svn+ssh://user@server/path/to/svn/repository

Flattr this

40 Comments on “Windows, svn+ssh and the Subversion command line client”

  1. Felix says:

    Hi! Thanks for the all the hints, I am actually trying to get svn to work with Matlab on windows.
    Your step-by-step instructions to get svn to work from the command line should do the trick, and it works fine until I get to test it using snv co …
    I get an ‘svn: connection closed unexpectedly’
    Login in with plink works fine, although I am prompted to give the passphrase for the private key.
    I suppose this is what happens when I try to connect using svn…
    and that I’m doing something wrong.
    Any help greately appreciated!

  2. Aurélien says:

    Hi felix
    I must confess I never tried to use svn and plink with a passphrase-protected key. You could try without passphrase but I guess that’s not what you are looking for…
    Maybe the pageant program from putty website can help you, quoting the site, it’s “an SSH authentication agent for PuTTY, PSCP and Plink”. I haven’t tried it yet.

  3. Daniel says:

    Thanks for the pointers to plink and the subversion config file.

    I’ve got this working now with a passphrase protected key. Just as you guessed pageant does the trick. Load the key into pageant it will ask you for the passphrase, and then plink and putty will get the key from pageant.

  4. Eric says:

    If you are a Vista user you’ll the path to the config file is different from that given above, rather it is:


  5. alok says:

    It worked for me —
    Following steps I have done
    1) open config – plink.exe is in my path var.
    # ssh = $SVN_SSH ssh
    ssh = plink.exe
    2) start Pageant – load xyz.ppk
    3) from cmd – svn update –

  6. AndriyK says:

    This is really useful step-by-step instruction.
    Thanks to Aurélien and others.

    I think that text from putty’s manual could be helpful:

    You may also need to ensure that your home directory, your .ssh directory, and any other files involved (such as authorized_keys, authorized_keys2 or authorization) are not group-writable or world-writable. You can typically do this by using a command such as

    chmod go-w $HOME $HOME/.ssh $HOME/.ssh/authorized_keys

  7. Stefan says:

    Hi all,
    I am using a passphrase-protected key generated with openssh. Unfortunately pageant can not work with this key. As an alternative svnkit provides also a good command line client.

  8. cooky says:

    I have the same problem as Felix in the first entry.
    plink works even without passphrase but as soon I start svn an error rises:
    ’svn: connection closed unexpectedly’

    I’ve tried for hours but now I have no more idea.
    Any hint is welcome.


  9. plebe says:

    1. There is not environment variable $HOME on Window 2003 server. Should it be $HOMEPATH?

    2. The plink -i … command gives
    FATAL ERROR: Network error: Connection refused
    No firewall is installed on the windows 2003. Anyone
    have a solution?

  10. acton says:

    thx. great

  11. ndgiang says:

    me got FATAL ERROR too. dont know why pls help us thanks

  12. Anthony says:


    I have setup SVN+SSH on my server, but when I try to test the SSH user access, I hit a tiny block.

    This command:

    command=”/usr/bin/svnserve -t -r /home/[site5-username]/svn/[projectx]
    –tunnel-user=[subversion user name]”,no-port-forwarding,no-agent-forwarding,no-X11-forwarding,no-pty [public key text from]

    creates the SSH user. But the last part “[public key text from]” seems to be my problem. Is this the password of the user that I just created?

    I have tried to test the SSH login, and it is not accepting that as user password.

    Thanks in advance (from a new SVN user)


  13. Anthony says:

    PS: I’m running windows Vista on my PC. But my server is UNIX and I am SSH-ing via SmartSVN.

  14. Baronozone says:

    Thanks for the help — it got me off to a good start (after much frustration).

    I’ve been writing a test program using pySVN that I wanted to distribute to several sites (Windows XP systems) to access several SVN repositories for automated testing. One thing I didn’t want was to have to load the Subversion server on all the remote systems, just so I could edit the config file with:
    ssh=c:/path/to/plink.exe, which did get me running on my development system — but I’m running a local server on that system anyway.

    The solution was to add the following variable to the system environment variables (or user variables) on the remote systems:
    SVN_SSH c:/path/to/plink.exe

    or if you prefer the backslash:
    SVN_SSH c:\\path\\to\\plink.exe

    I have Pageant running with the key selected on each system with PuTTY configured with the session connection details as well. So no need to load anything other than my application and Putty/Pageant/Plink on each system. (You wouldn’t think you’d need a server on every system for client access anyway!)


  15. jack says:

    Nice article,

    However don’t forget to specify the port if you changed it to something else. Security wise, it’s a good thing to do:

    if your port is 25000, then:

    ssh=c:/path/to/plink.exe -i c:/path/to/your/key.ppk -P 25000

  16. alessandro says:

    Thank you: very useful tips !

  17. shawn says:

    Firstly, great post and comments, they helped me a great deal!

    I had everything pretty much set up the way everyone else described with svn, plink and pageant with a passphrase and still got the “connection closed unexpectedly”

    I finally got things to work after forcing some options in the svn config file:

    -load “savedprofile”

    “-load” causes plink to use a saved profile (this was just convenient)
    “-l” specifies the user account you want to use
    “-agent” instructs plink to use pageant

    Not all of this is required I’m sure… but if you’re using pageant and think you have everything else setup but still get the error, try forcing some of these options.

    In my svn config file, it reads like this now:

    ssh = c:/plink.exe -load myputtyprofilename -l -agent

  18. For people who can’t get plink (or PuTTY) to work, I wrote an article on how to get SVN access on Windows with the SSH client from Git.

  19. Rick says:

    If you’re using a Windows client with a Linux host (server), be SURE to generate your keys on the server using ssh-keygen. The keys generated on Windows definitely don’t work when copied over to Linux (not sure why).

    If you generate the RSA keys on the server, then move your private key file to your Windows PC, you’ll find that the “plink” example above actually works on Windows.

    Hope that’s helpful (cost me several hours of wasted time, hopefully you’ll read this and save that time)


  20. GreenT says:


    You can download some tools from this site.

    Installing the client tool will give you command line functionality as well


  21. Mark says:

    For those of you using a passphrase protected key remember to add the key to pageant otherwise your plink commands will just hang.

  22. Krommenaas says:

    Thank you, after three days of trying to connect to a svn repository I set up at my webhost from my XP machine, this page finally helped me do it:)

  23. ppo says:

    in case you can’t find the config files after svn fresh install you need to run at least once some reasonable svn command like svn -version to have them created in Application Data directory.

  24. Martin Ferrari says:

    Great!!! Very much thank you!!!

  25. Colin says:

    ssh=c:/path/to/plink.exe -i c:/path/to/your/key.ppk

    should read

    ssh=c:/path/to/plink.exe -l loginname -i c:/path/to/your/key.ppk

    At least it solved my problem anyway.

  26. Jaisal says:


    I am using Tortoise SVN and the subversion repository(server) is not local and has https: in it. In this case will the same solution work?

  27. miro ilias says:

    Hi all,

    I have played a lot with svn co svn+ssh… a found that the recommended “plink.exe” is not working for svn co. It is, however, working for direct ssh connection.

    So I have switched to TortoiseSVN,, from where I employed the “TortoisePlink.exe”, which I have put int o my svn config (SlikSVN program) as “ssh=TortoisePlink.exe -v -i C:\\Users\\…\\myprivatekey.ppk”

    Now I am able to connect my svn server.

    Best, M.

  28. Bala says:

    Is this type of connection using pageant and plink is it encrypted and safe.

    In words the data that is transferred through the connection is it encrypted.


  29. Sadik says:

    I tried it with plink and it did not help. plink seems not to function or so.
    So I tried cygwin:
    ssh=c:/path/to/cygwin /bin/ssh.exe -i c:/path/to/your/key.ppk

    It says:
    authenticity of host ‘…’ can’t be established
    RSA key fingerprint is 3f: ……….
    Are you sure you want to continue connectin? (yes/no)

    After typing yes I have to enter my passphrase. Although Im tiping the correct one he wants me to enter it again, 3 times. After 3rd time all is over. I dont get connection.

    Tortoise does not help me in no way.
    I don’t know what to test now

  30. Rick says:

    OK. Here’s how I fixed this (on Mac OS X, but fix should work on any client)

    This particular issue arises when you are using a non-standard port (let’s say 12001 for sake of example) for your SSH server.

    Apparently the SVN client experiences syntax errors when given a port address on a command line like this one:

    svn list svn+ssh://

    So, to fix this, you need to create a client-side config file for SSH like this:

    cd ~
    cd .ssh
    vi config (create a config file like the one that follows)

    Config file located in ~/.ssh/config:

    User username
    Port 12001

    Then, issue your svn+ssh command WITHOUT the port like this:

    svn list svn+ssh://

    That’s it!

    Hope that helps.

  31. airborne says:

    Tortoise comes packed in with Plink now.

  32. Timothy says:

    This was very helpful… thank you for putting this out there; you saved me much the same headache.

  33. Rik says:

    Thank you:)

  34. […] it might be necessary to use the non-putty generated key on the linux svn server. Or as mentioned here you should copy paste the key from the field that states “Public key for pasting into OpenSSH […]

  35. silvansky says:

    Thanx a log! You saved my time.

  36. Zazou says:

    In case of error : “The server’s host key is not cached in the registry”
    Just run psftp.exe in the Putty install directory.
    Connect to the server, and answer Y to the question.
    After this, the question is never ask again.


Get every new post delivered to your Inbox.