Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In my case, I want to do a SVN checkout:

svn co svn+ssh://

However, I want to have the password in that one line, so that it doesn't pop up.

share|improve this question

migrated from Nov 17 '09 at 3:03

This question came from our site for professional and enthusiast programmers.

Just a quick warning - your username and password will be exposed to ANYONE with access to that machine. Just a simple "ps -elf" command will show the full command line. In general this is not a good idea security-wise, and why svn and tools like it prompt for passwords. Not that you can't do it if you control who has access to the system, just don't want people to think they should do this in general. – Jared Jun 9 '14 at 14:44
up vote 10 down vote accepted

svn co svn+ssh://username:password@

share|improve this answer
+1 for answering the question and not just providing alternatives (worthy though they may be). – briealeida Nov 19 '09 at 3:59
@briealeida - I just wish it worked: according to the test in my post below, it seems it does not work, as a password prompt appears anyways; the same post contains a solution with sshpass (which does work for me). – sdaau Apr 22 '13 at 8:46
As said above, this doesn't actually work. – Jonny Oct 6 '15 at 21:30
Expanded: it would likely work as long as ssh does not ask for a password, which it would in most cases. – Jonny Oct 8 '15 at 4:44

Given that you're using SSH, the preferred way is to use a public key for authorization, which saves the need of a password completely.

A guide for creating and installing the keys can be found here.

share|improve this answer
Of course, if you want your key to be really secure, you should give it a pass phrase. :/ – Rob Jan 20 '12 at 3:03

Infinitely better is to generate a keypair. As your local user:

$ ssh-keygen -t rsa

(accept all defaults)

Then take the contents of .ssh/ and add it on the remote server to .ssh/authorized_keys Be very sure it is all pasted into the same line. Also be very sure the permissions of the .ssh directory are 600.

Then you should be able to ssh without being prompted for a password.

share|improve this answer
"The permissions of ~/.ssh on the server should be 700. The file ~/.ssh/authorized_keys (on the server) is supposed to have a mode of 600. The permissions of the (private) key on the client-side should be 600." – Jonny Oct 6 '15 at 21:43

Instead of using a password you might want to have a look at a private/public key pair and have ssh use that. most linux distributions come with easy to use commands to create such a pair. this would however require access ti the server side (once) to deposit the public key file in your user's ~/.ssh/authorized_keys file.

share|improve this answer

Well, I do want to enter a password - I don't like relying on my password being saved somewhere; however, I do want to enter it once per set of svn+ssh commands; and often, you just want to do one svn checkout - and have to enter tons of passwords anyways. It is in such a case I'd like to type a password only once.

So, only answers by @Boinst and @Marius were relevant for my use case; unfortunately, they didn't help, as I couldn't get them to work. I wonder if the post authors themselves tried the commands out before posting them, as now I cannot imagine how they could work - here's a test I did locally on my Ubuntu 10.04 PC (and I break with Ctrl-C, each time I see the password prompt appear):

$ svn --version | head -1
svn, version 1.6.6 (r40053)

$ cd /tmp
$ svnadmin create myrepo
$ read -p 'ssh myself@ ' PASS
ssh myself@ [type _PASSWORD_, press ENTER]

## trying first with 
# (specify in URL user:pass separated by colon)

## plain ssh - asks for password anyway:

$ ssh myself:$PASS@
myself:_PASSWORD_@'s password: ^C

# svn - with just username, as expected:

$ svn co svn+ssh://myself@ myrepo-wc
myself@'s password: ^C
svn: Network connection closed unexpectedly

# svn - with password added to URL, asks for password anyway:

$ svn co svn+ssh://myself:$PASS@ myrepo-wc
myself:_PASSWORD_@'s password: ^C
svn: Network connection closed unexpectedly

# trying then with,
# (--non-interactive and --username/--password on command line)

# svn - asks for password anyway:

$ svn co svn+ssh://myself@ --non-interactive --trust-server-cert --username myself --password $PASS --no-auth-cache
myself@'s password: ^C
svn: Network connection closed unexpectedly

As far as --username/--password on svn command line is concerned - that doesn't matter with svn+ssh, because it's ssh asking, not svn:

svn - Subversion ignoring "--password" and "--username" options - Stack Overflow

The prompt you're getting doesn't look like Subversion asking you for a password, it looks like ssh asking for a password.

Additionally, as the log shows, ssh itself doesn't accept "username:password@..." in the URL - and so neither does svn. Why it is acceptable to use only username in the URL in svn, is probably explained in ~/.subversion/config:

### (If the URL includes a username, then the hostname will be
### passed to the tunnel agent as @.)

Notice nothing is said about <user>:<pass>@<hostname>.

Now, thanks to the page Subversion over SVN+SSH on Debian, I finally realized there is a SVN_SSH environment variable used in ~/.subversion/config for the (I guess) ssh tunnel; and that finally opens up the possibility to use the program sshpass to handle the password in such a one-way manner:

$ SSHPASS=$PASS SVN_SSH="sshpass -e ssh" svn co svn+ssh://myself@ myrepo-wc
Checked out revision 0.

Well, at least I'm glad I finally found a solution that works for me - hope this helps someone else, too,

share|improve this answer

You can also use the given switches username and password.

Refer Command-line authentication.

share|improve this answer
svn co svn+ssh:// --non-interactive --trust-server-cert --username <username> --password <password> --no-auth-cache
share|improve this answer

I think using sshpass (in Linux) is the best way to get this.

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
share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .