简体   繁体   中英

svn + ssh without password from command line?

I want to do

svn update /Users/radek/Sites/3.0.5/ -r HEAD --force

without the need of typing the password.

svn connects to our repository server but I am not sure under what username (how can I find out?). I guess it would be either root or radek

The password I type for svn to proceed is the same like root's one on repository server so I added my public key to root's authorized_keys file. So I ssh to repository server without typing password but it did not affect svn asking for password at all. The password of user radek on repository server is different to the one I type for svn up

If I commit something form Eclipse the author is radek.

Solution

svn info

told as which user I have to log in into repository server and then I added public key to its authorized_keys file. Now I do not have to enter pass when using svn.

There is a program called "ssh-agent" that will save an unlocked RSA or DSA key in memory and supply this key to SSH through a UNIX socket. This can be used for "password-less" SSH connections, assuming you generate an RSA or DSA public/private key pair, and add the public key to the "authorized_keys" or "authorized_keys2" file of the remote host. When you first add a key to ssh-agent or turn on ssh-agent, you will need to supply your password, but subsequent uses of SSH can occur without a password. You may find the following articles helpful in terms of setting up SSH agent:

Note that on Mac OS X (as of 10.5 and higher), if you generate the private/public key pair and put the public key in the authorized_keys file of the remote host, when you SSH into that host, Mac OS X will automatically start up its own ssh-agent (no setup required) and offer to remember the password (it will save it in KeyChain). You can read more about that on Mac OS X Leopard -- Built-In SSH Agent .

If you can't use a key file, use sshpass (in Linux):

Install sshpass

$ sudo apt-get install sshpass

Set the temporary environment variable

$ export SSHPASS=yourpass

Edit the svn config file

$ nano ~/.subversion/config

Finally comment out add sshpass -e to ssh line, before the ssh command

ssh = $SVN_SSH sshpass -e ssh -q -o ControlMaster=no

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM