SHARE
TWEET

Untitled

a guest Apr 18th, 2019 86 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # Add following code at the end of ~/.bashrc
  2.  
  3. # Check if ~/.pid_ssh_agent exists.
  4. if [ -f ~/.pid_ssh_agent ]; then
  5.  
  6.     source ~/.pid_ssh_agent
  7.  
  8.     # Check process of ssh-agent still exists.
  9.     TEST=$(ssh-add -l)
  10.  
  11.     if [ -z "$TEST" ]; then # Reinit if not.
  12.         NEED_INIT=1
  13.     fi
  14. else
  15.     NEED_INIT=1 # PID file doesm't exist, reinit it.
  16. fi
  17.  
  18. # Try start ssh-agent.
  19. if [ ! -z "$NEED_INIT" ]; then
  20.     echo $(ssh-agent -s) > ~/.pid_ssh_agent # save the PID to file.
  21.     source ~/.pid_ssh_agent
  22. fi
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top