This isn't a command, but a set of zsh scripts I've written. I've attached them. If you want to use them, you basically need to put these files somewhere in your $fpath, autoload the corresponding functions with autoload -U _call_sshagent _call_sshadd kill_sshmasters call _call_sshagent from your .zlogin and add the following to your .zlogout: # Unregister from ssh-agent and kill it if need be. if [[ -n $SSH_AUTH_SOCK ]] then if [[ `whence -w _call_sshagent` == '_call_sshagent: function' ]] then _call_sshagent -r elif [[ -n $SSH_AGENT_PID ]] then eval `ssh-agent -k` fi fi and use the following wrappers: ssh() { _call_sshadd "$@" command ssh "$@" } slogin() { _call_sshadd "$@" command slogin "$@" } scp() { _call_sshadd "$@" command scp "$@" } sftp() { _call_sshadd "$@" command sftp "$@" } Note: here, these wrappers are defined in .zalias (so is the autoload line I've mentioned above), sourced by my .zshrc file. Also, I've set SVN_SSH to $HOME/scripts/ssh; this script contains: source ~/.zshenv source ~/.zalias unset DISPLAY ssh -C "$@" Note that $HOME/scripts must not be in $path to avoid an infinite recursion. In fact, it would be more robust to dynamically remove $HOME/scripts from $path before calling ssh, after resolving hard and symbolic links. But there should be no problem if you do not have '.' in your $path or if you have it at the end (having '.' earlier in $path is a security problem anyway). This way, one no longer needs to call ssh-agent and/or ssh-add manually. The passphrase is automatically asked at the first connection attempt and remembered until the last login shell exits. However, one still needs to execute ssh -fMN manually for ssh connection caching. You can add lines to some ssh wrapper to do that automatically, but you need to check for the corresponding ControlSocket file first, otherwise there will be no benefit; unfortunately this is not easy... About these problems, you can see my bug report and followup here: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=335697 Also, note that lsof is used to find the ssh master connection. If you do not have lsof, the ssh master connection will not be killed. The kill_sshmasters script has an echo line to let you know that this connection is killed. So, you know what happens. Standard disclaimer: use these scripts at your own risks. I've written them with security in mind, but they haven't be reviewed by anyone else. Also, I've written them for my config on various machines, and I'm not sure they work correctly everywhere. You can still check that ssh-agent is killed when you completely logout with a ssh host ps -aef | grep ssh-agent ^^^^ or other options depending on your system, and things like that. -- Vincent Lefèvre - Web: 100% accessible validated (X)HTML - Blog: Work: CR INRIA - computer arithmetic / SPACES project at LORIA