Reputation: 3388
I need a script that updates my copy of a repository. When I type "svn up" I usually am forced to enter a password, how do I automate the password entry?
What I've tried:
import pexpect, sys, re
pexpect.run("svn cleanup")
child = pexpect.spawn('svn up')
child.logfile = sys.stdout
child.expect("Enter passphrase for key \'/home/rcompton/.ssh/id_rsa\':")
child.sendline("majorSecurityBreach")
matchanything = re.compile('.*', re.DOTALL)
child.expect(matchanything)
child.close()
But it does not seem to be updating.
edit: If it matters, I can get my repository to update with child.interact()
import pexpect, sys, re
pexpect.run("svn cleanup")
child = pexpect.spawn('svn up')
child.logfile = sys.stdout
i = child.expect("Enter passphrase for key \'/home/rcompton/.ssh/id_rsa\':")
child.interact()
allows me to enter my password and starts updating. However, I end up with an error anyway.
-bash-3.2$ python2.7 exRepUpdate.py
Enter passphrase for key '/home/rcompton/.ssh/id_rsa':
At revision 4386.
At revision 4386.
Traceback (most recent call last):
File "exRepUpdate.py", line 13, in <module>
child.interact()
File "build/bdist.linux-x86_64/egg/pexpect.py", line 1497, in interact
File "build/bdist.linux-x86_64/egg/pexpect.py", line 1525, in __interact_copy
File "build/bdist.linux-x86_64/egg/pexpect.py", line 1515, in __interact_read
OSError: [Errno 5] Input/output error
edit: Alright I found a way around plaintext password entry. An important detail I left out (which, honestly, I didn't think I'd need since this seemed like it would be an easy problem) is that I had to send a public key to our IT dept. when I first got access to the repo. Avoiding the password entry with in the ssh+svn that I'm dealing with can be done with ssh-agent. This link: http://mah.everybody.org/docs/ssh gives an easy overview. The solution Joseph M. Reagle by way of Daniel Starin only requires I enter my password one time ever, on login, allowing me to execute my script each night despite the password entry.
Upvotes: 0
Views: 699
Reputation: 22690
If you don't want to type password many times, but still have a secure solution you can use ssh-agent to keep your key passphrases for a while. If you use your default private key simply type ssh-add
and give your passphrase when asked.
More details on ssh-add
command usage are here: linux.die.net/man/1/ssh-add
Upvotes: 1
Reputation: 287885
You should really just use ssh with public keys.
In the absence of that, you can simply create a new file in ~/.subversion/auth/svn.simple/
with the contents:
K 8
passtype
V 6
simple
K 999
password
V 7
password_goes_here
K 15
svn:realmstring
V 999
<url> real_identifier
K 8
username
V 999
username_goes_here
END
The 999 numbers are the length of the next line (minus \n
). The filename should be the MD5 sum of the realm string.
Upvotes: 0