Sam McAfee
Sam McAfee

Reputation: 10133

How do I get a SVN checkout using a Public/Private key pair?

I have to check some code and run it. I have the URL:

svn+ssh://[email protected]/home/svn/project/trunk

I have a file with their private key. What do I do to get this code?

Upvotes: 30

Views: 75112

Answers (8)

Legolas Bloom
Legolas Bloom

Reputation: 1805

SVN_SSH="ssh -i /xxx/xxx/id_rsa" svn checkout svn+ssh://[email protected]/data

Upvotes: 0

Zied
Zied

Reputation: 346

Add this entry to your ~/.ssh/config file:

Host YOUR_SERVER
IdentityFile YOUR_PRIVATE_KEY_PATH # (ex: ~/.ssh/rsa)
User USER_NAME

For more options, see the ssh_config man page.

Upvotes: 16

uı6ʎɹnɯ ꞁəıuɐp
uı6ʎɹnɯ ꞁəıuɐp

Reputation: 3481

In addition to the answers two screen shots from Eclipse 3.7 with Subversive.


General settings
Enter the user name! (I have forgotten this before taking the screen shot). Do not enter a password.


SSH Settings Enter the key passphrase if you private key is passphrase protected.


A picture is worth a thousand words.

Upvotes: 2

David
David

Reputation: 905

If you need to use a custom key just for svn, the following will work:

SVN_SSH="ssh -i /path/to/key_name"

export SVN_SSH

svn commands

http://labs.kortina.net/2010/01/30/svn-checkout-with-private-key-over-ssh/

Upvotes: 60

kay am see
kay am see

Reputation: 988

just use ssh-add command (it will ask your for your password, this is the password you used when you created this public private key pair ).

ssh-add PATH_TO_YOUR_PRIVATE_JEY
e.g. ssh-add ~/.ssh/myPrivateKey.key

verify that you added the key correctly by doing this

ssh-add -l

That will list all identity files it is using.

Upvotes: 8

Swaroop C H
Swaroop C H

Reputation: 17034

Add the private key to your ~/.ssh/ folder and then run ssh-agent $SHELL; ssh-add;, and then the svn co of that URL should work.

Upvotes: 1

ryatkins
ryatkins

Reputation: 348

Here are the steps that I used to connect from the Mac OS X command line to my server via svn+ssh:

On server:

ssh-keygen -b 1024 -t dsa -f mykey   (creates mykey and mkey.pub files)

Copy contents of mykey.pub to ~/.ssh/authorized_keys (create authorized_keys file if it doesn't exist)

Download mkey to your local machine and run:

chmod 600 mkey  (the next step won't run otherwise)
svn-add mkey  (enter your passphrase)

checkout from your svn server with ssh:

svn co svn+ssh://[email protected]/repos/path

Delete mkey and mkey.pub from your server

Upvotes: 2

ephemient
ephemient

Reputation: 204926

The private key goes on the client machine, often named as ~/.ssh/id_rsa, ~/.ssh/id_dsa, or ~/.ssh/identity depending on the SSH version and the type of key. However, you can just use ssh -i path/to/private.key.

This is presuming that the corresponding public key exists on the server in ~/.ssh/authorized_keys, and that your local machine is running the OpenSSH client. If you are using PuTTY on Windows, simply open up the Pageant program, and import the key via the GUI.

Upvotes: 5

Related Questions