Making Subversion remember passwords

If you do not mind having Subversion store plain-text passwords as it had in past version—e.g., if you have a Linux box that nobody else has access to—you can regain the old behaviour with a bit of manual work for each repository.

After you have checked-out a repository there will be a file created in $HOME/.subversion/auth/svn.simple/. You will find a text file there for each repository, so you might have to dig around to find the one(s) you want, or you can just do them all. The idea is to manually add the password into the file(s), and then Subversion will see and use it.1)

The lines you need to add are these:

K 8
passtype
V 6
simple
K 8
password
V 18
my secret password

For the last two lines replace the # with the number of characters in your password and then put your password on the last line.

Here is a handy script to insert the same credentials into all of your SVN config files that do not already have a stored password. To be clear: If you use different passwords for repositories then you will not want to do this.

I save this script as /usr/local/bin/svn-add-password on my Linux boxes:

#!/bin/bash
# Add Subversion password to any files that are missing it.

read -sp "SVN password to place in config files: " pass
echo
if [[ -n $pass ]]
then
        passlen=${#pass}
        for f in ~/.subversion/auth/svn.simple/*
        do
                k=$(grep -c password $f)
                [[ $k -gt 0 ]] && continue
                repo=$(grep "svn://" $f)
                printf "Adding password to %s\n" "$repo"
                sed "s/END/K 8\npasstype\nV 6\nsimple\nK 8\npassword\nV ${passlen}\n${pass}\nEND/" -i $f
        done
fi

Ringraziamenti a LSerni da Firenze, Italia per queste informazione in questo post su stackoverflow.

1)
This is verified with version 1.41.1