svn + ssh without password from command line?

断了今生、忘了曾经 提交于 2019-12-19 05:58:05

问题


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.


回答1:


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:

  • Using ssh-agent with ssh
  • Shortest passwordless ssh tutorial, ever
  • How-To: "Password-less" SSH

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.




回答2:


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


来源:https://stackoverflow.com/questions/5114012/svn-ssh-without-password-from-command-line

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!