首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何用python永久启动ssh-agent?

如何用python永久启动ssh-agent?
EN

Stack Overflow用户
提问于 2017-10-19 19:54:26
回答 1查看 2.7K关注 0票数 1

我正在寻找相当于python的eval $(ssh-agent),它将启动ssh代理,并在脚本完成后继续运行以运行。

我对谷歌没有发现任何有用的东西。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-10-20 15:39:53

我试图使用那个https://pypi.python.org/pypi/ssh-agent-setup/0.2.0,但它对我不起作用。看一下https://github.com/haarcuba/ssh-agent-setup上的代码,我发现这是很容易修复的。我做了叉子,并做了拉请求https://github.com/haarcuba/ssh-agent-setup/pull/2

对于那些对使用ssh代理安装python模块感兴趣的人,您可以按照https://github.com/haarcuba/ssh-agent-setup#ssh-agent-setup指令进行操作。

如果你得到:

代码语言:javascript
复制
ssh_agent_setup.setup()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.6/site-packages/ssh_agent_setup/__init__.py", line 34, in setup
    _setupAgent()
  File "/usr/local/lib/python3.6/site-packages/ssh_agent_setup/__init__.py", line 18, in _setupAgent
    raise Exception( 'Could not parse ssh-agent output. It was: {}'.format( process.stdout ) )
Exception: Could not parse ssh-agent output. It was: setenv SSH_AUTH_SOCK /tmp/ssh-thoTQTiOTR0y/agent.47524;
setenv SSH_AGENT_PID 47797;
echo Agent pid 47797;

修复是https://github.com/haarcuba/ssh-agent-setup/pull/2/commits/d262228d379a4c58d357c7d5f83a579ca760e054#diff-39dd5525d88610b0c21a9bec4d2534b0

如果有人想要实现类似的东西,那么代码很容易理解.py

通过阅读代码,我现在了解了如何在python中启动ssh-agent。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/46837914

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档