How do I get a SVN checkout using a Public/Private

2019-01-30 11:42发布

问题:

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

svn+ssh://myuser@www.myclient.com/home/svn/project/trunk

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

回答1:

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.



回答2:

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/



回答3:

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.



回答4:

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.



回答5:

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://user@server.com/repos/path

Delete mkey and mkey.pub from your server



回答6:

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



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


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


A picture is worth a thousand words.



回答7:

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.



标签: svn ssh key