Difference between revisions of "ssh-agent user setup and on demand ssh-add"

From thelinuxwiki
Jump to: navigation, search
Line 13: Line 13:
 
   trap "kill $SSH_AGENT_PID" 0
 
   trap "kill $SSH_AGENT_PID" 0
 
  fi
 
  fi
 
 
  # alias that checks for existing ssh-add identities
 
  # alias that checks for existing ssh-add identities
 
  alias ssh="( ssh-add -l > /dev/null || ssh-add ) && ssh"
 
  alias ssh="( ssh-add -l > /dev/null || ssh-add ) && ssh"

Revision as of 21:37, 20 January 2014

DESCRIPTION (from man page)

    ssh-agent is a program to hold private keys used for public key authentication (RSA, DSA, ECDSA).  The idea is that
    ssh-agent is started in the beginning of an X-session or a login session, and all other windows or programs are
    started as clients to the ssh-agent program.  Through use of environment variables the agent can be located and
    automatically used for authentication when logging in to other machines using ssh(1).

to enable (assuming it is already installed) add the following lines to .bash_profile in the user home directory

#ssh-agent start n stop for bourne shell
SSHAGENT=/usr/bin/ssh-agent
SSHAGENTARGS="-s"
if [ -z "$SSH_AUTH_SOCK" -a -x "$SSHAGENT" ]; then
 eval `$SSHAGENT $SSHAGENTARGS`
 trap "kill $SSH_AGENT_PID" 0
fi
# alias that checks for existing ssh-add identities
alias ssh="( ssh-add -l > /dev/null || ssh-add ) && ssh"

ssh-agent install check

check for binary, if you get a path back it is installed

# which ssh-agent
/usr/bin/ssh-agent