I am looking for the equivalent of eval $(ssh-agent)
for python, that will start ssh-agent and will stay running after the script finish to run.
I didn't find anything useful with Google.
I was trying to use that https://pypi.python.org/pypi/ssh-agent-setup/0.2.0, but it was not working for me. Looking at the code on https://github.com/haarcuba/ssh-agent-setup I have found out that is was pretty easy to fix. I did fork and do a pull request https://github.com/haarcuba/ssh-agent-setup/pull/2.
For those who are interested in using ssh-agent-setup python module, you can follow the instruction https://github.com/haarcuba/ssh-agent-setup#ssh-agent-setup.
If you get:
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;
If anyone wants to implement a something similar the code is pretty easy to understand https://github.com/haarcuba/ssh-agent-setup/blob/master/ssh_agent_setup/__init__.py.
Reading the code, I now understand how ssh-agent can be started in python.