ssh-agent: ssh-add before first ssh

To get “ssh-add” executed before first use of “ssh host_xyz” add:

ssh() {
      ssh-add -L >/dev/null 2>&1
      [ $? = 1 ] && ssh-add
      command ssh "$@"
      unset -f ssh
}

to your .bashrc

found at secure-shell mailinglist (Canssh add keys to ssh-agent?)

This entry was posted in Uncategorized. Bookmark the permalink.