我需要一个脚本来更新我的存储库副本。当我输入“svn up”时,我通常被迫输入密码,如何自动输入密码?在
我所做的:
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()
但它似乎没有更新。在
编辑:如果重要,我可以让我的存储库更新儿童互动()
^{pr2}$允许我输入密码并开始更新。但是,无论如何,我最终还是犯了一个错误。在
-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
编辑:好吧,我找到了一种绕过明文密码输入的方法。我遗漏了一个重要的细节(老实说,我认为我不需要这个,因为这看起来是一个简单的问题),那就是当我第一次获得回购时,我必须向我们的it部门发送一个公钥。在ssh+svn中避免密码输入可以通过ssh代理来完成。这个链接:http://mah.everybody.org/docs/ssh提供了一个简单的概述。Joseph M.Reagle通过Daniel Starin的方式只需要我在登录时输入一次密码,这样我就可以每天晚上执行我的脚本,尽管密码输入了。在
实际上,您应该将ssh与公钥一起使用。在
如果没有,您只需在
~/.subversion/auth/svn.simple/
中创建一个新文件,其中包含以下内容:999个数字是下一行的长度(减
\n
)。文件名应该是领域字符串的MD5和。在如果您不想多次输入密码,但仍然有一个安全的解决方案,您可以使用ssh代理来保存您的密钥密码短语一段时间。如果您使用默认私钥,只需键入
ssh-add
并在询问时提供密码短语。在有关
ssh-add
命令用法的详细信息如下:linux.die.net/man/1/ssh-add相关问题 更多 >
编程相关推荐