Fabric 和 svn 密码
假设我无法使用 Fabric 运行类似的操作:
run("svn update --password 'password' .")
将远程交互式命令行的密码传递给 Fabric 的正确方法是什么?
问题是仓库被签出为 svn+ssh 并且我没有 http/https/svn 选项
Assuming that I cannot run something like this with Fabric:
run("svn update --password 'password' .")
how's the proper way to pass to Fabric the password for the remote interactive command line?
The problem is that the repo is checked out as svn+ssh and I don't have a http/https/svn option
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
尝试 SSHkey。它允许您无需密码即可连接到服务器。
在这种情况下,您必须在远程服务器和存储库之间设置 sshkey。
在远程服务器上:生成密钥对
将密码阶段留空!
这将生成 2 个文件
然后,将 id_dsa.pub 中的内容附加到 repo 服务器上的 ~/.ssh/authorized_keys 中。
您的远程服务器将能够更新源代码树,无需任何密码。
Try SSHkey. It allows you to connect to the server without password.
In this case, you will have to setup a sshkey between your remote server and the repo.
At remote server: Generate key pair
Leave the passphase empty!
This will generate 2 files
Then, append the content in id_dsa.pub to ~/.ssh/authorized_keys at repo server.
Your remote server will be able to update the source tree without any password required.
如果您只是想在日志中隐藏密码,您可以使用如下内容:
If yout just want to hide your password from log, you can use something like this:
不久前我们遇到了类似的问题,实际上为 Fabric 提出了一个新功能,但我们采访的开发人员却建议这样做。
当结构运行此命令时,这将提示您输入密码。
不过,我相信这会在结构日志中显示您的密码,因此更好的选择是让 SVN 提示您输入密码并将密码回显到其中。
不过我不使用 SVN,所以我担心我不确定这是否可能。我希望其他人可以提供帮助!
We had a problem similar to this a while back and actually proposed a new feature for Fabric, but the developer we spoke to suggested this instead.
This will prompt you for a password when the time comes for fabric to run this command.
I believe that will display your password in the fabric log, however, so a better option would be to get SVN to prompt you for the password and echo the password into it.
I don't use SVN though, so I'm afraid I'm not sure if that is possible. I hope someone else can help there!
我对自动化交互式命令行的标准答案是“使用 Expect”,但您使用的是 Python,所以我将稍微改进为“使用 期望"。
将 Pexpect 集成到 Fabric 中可能需要一些思考,或者对于这种特殊情况,您最终可能会单独使用 Pexpect。但这绝对是我会走的路。
My standard answer for automating interactive command lines is "use Expect", but you're using Python, so I will slightly refine that to "use Pexpect".
It might take a bit of thought to integrate Pexpect within Fabric, or perhaps you will just end up falling back to Pexpect alone for this particular case. But it's definitely the way I would go.
您可能还需要向用户提供?如果没有,您可能会更好地导出您的存储库并对其进行 tar(本地)以在服务器上上传+部署。如果您在本地运行 svn 命令,系统将提示您输入用户名和/或密码。
You might need to supply the user as well? If not, you may have better luck exporting your repo and making a tar of it (locally) to upload+deploy on the server. If you run the svn commands locally, you'll be able to get prompted for your username and/or password.
您应该查看 Fabric 的 env 文档。有人说你应该做这样的事情:
希望它有帮助!
You should take a look at the Fabric's env documentation. There states that you should make something like this:
Hope it helps!