Monday, May 29, 2017

make ssh-agent run automatically

1. Start up the agent by adding the following in .profile, assume key file is called interop:

if [ -z "$SSH_AUTH_SOCK" ] ; then
  eval `ssh-agent -s`
  ssh-add ~/.ssh/interop
fi
2. Kill the agent when log out by adding the following in .bash_logout:
trap 'test -n "$SSH_AGENT_PID" && eval `/usr/bin/ssh-agent -k`' 0

No comments:

Post a Comment