Advertisement
Guest User

Untitled

a guest
Apr 18th, 2019
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  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
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement