I had some trouble finding how to run ssh-agent, so I'm just creating this to provide the info.
source-bash eval "$(ssh-agent -s)" && ssh-add ~/.ssh/github_rsa
If there will be more than one user on the machine it may be wise to take additional ssh-agent security steps.
I would actually be tempted to do parsing on the output, but it looks like standard ssh-agent doesn't have an easily-parsed option. (-c might be easier to parse than -s, though.)
In any case, this should probably be a xontrib, because it's super common, and it should make an effort to not duplicate. (Is that a thing that _can_ be done?)
make an effort to not duplicate. (Is that a thing that can be done?)
I think that works best when someone else is doing it!
But really, If there isn't a trivial workaround another option may be for the xontrib to use an existing package that implements or interacts with an ssh agent in python?
My first google result: http://docs.paramiko.org/en/2.2/api/agent.html
This does the trick:
source-bash eval "$(ssh-agent -s)" && ssh-add ~/.ssh/rsa
Perhaps this should be added to the docs somewhere.
@ahundt - happy to have this in the docs! Please feel free to make a PR!
To persist ssh-agent across sessions (source):
from pathlib import Path
# ssh-agent
_SSH_AGENT_ENV=Path($XDG_RUNTIME_DIR + "/ssh-agent.env")
if not $(pgrep -u $USER ssh-agent):
_SSH_AGENT_ENV.write_text($(ssh-agent -s))
else:
if _SSH_AGENT_ENV.exists():
source-bash @(_SSH_AGENT_ENV)
else:
echo "ssh-agent is running but _SSH_AGENT_ENV not found! killall ssh-agent"