3

I have read docs on GitHub and found that I can start ssh-agent by eval $(ssh-agent -s). But it seems every time I execute this command, I am starting a new process of ssh-agent. How can I check if ssh-agent is already running from git bash in order to avoid start duplicated ssh-agent?

Update:Maybe because of my ignorance, I am not able to find much useful info related to my question in the provided link. I would like to know how to check whether ssh-agent has already been running or not. If yes, then how many? Not how to start ssh-agent or automatically to start it on git bash opening.

krave
  • 1,629
  • 4
  • 17
  • 36
  • Possible duplicate of [Getting ssh-agent to work with git run from windows command shell](https://stackoverflow.com/questions/3669001/getting-ssh-agent-to-work-with-git-run-from-windows-command-shell) – phd Dec 10 '18 at 20:59
  • https://stackoverflow.com/search?q=%5Bssh-agent%5D+check+running – phd Dec 10 '18 at 20:59
  • Hi, @phd could you please located relative info for me? I browsed the links you provided but found not much related with my question. I would like to know how to check whether ssh-agent has already been running or not. Not start ssh-agent or automatically start it on git bash opening. – krave Dec 11 '18 at 17:16
  • What are you gonna do if it's not started yet? – phd Dec 11 '18 at 17:59
  • The answer with `pgrep -q -U `whoami` -x 'ssh-agent'` answers exactly that — how to find out running processes. – phd Dec 11 '18 at 18:02
  • 1
    [This script](https://stackoverflow.com/a/15870387/7976758) uses `ps -f -u $USERNAME | grep ssh-agent` for the same task. – phd Dec 11 '18 at 18:04
  • @phd git bash complained that pgrep is not found. `ps -f -u $USERNAME | grep ssh-agent` works. Thank you! – krave Dec 11 '18 at 18:09

0 Answers0