Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'd like to have my keyfiles leave memory after a certain amount of disuse. Is there a way to make ssh-agent expire keys faster? It feels like it keeps them in memory and not needing a passphrase for really long periods of time.

share|improve this question
Have you seen the -t switch? – jasonwryan Feb 24 '12 at 22:05
up vote 7 down vote accepted

Pass the -t option to ssh-agent or to ssh-add. The argument can be a number of seconds or use other time units.

share|improve this answer
Since Ubuntu often launches the GUI passphrase tool automatically, is there a way that I can specify how long to have the key live for in a configuration file somewhere? – Naftuli Tzvi Kay Feb 26 '12 at 20:32
@TKKocheran ssh-agent is invoked from /etc/X11/Xsession.d/90x11-common_ssh-agent, so it's difficult to change it as a per-account setting. It may be possible, depending on the version of Ubuntu and the display manager and the desktop environment. Or you may be able to tune the GUI passphrase tool to pass -t, I don't know anything about it. – Gilles Feb 26 '12 at 22:49
@TKKocheran @Gilles The "graphical" agent from Gnome (Debian Squeeze) is used over ssh-agent by default, and to my knowledge, there is no way to configure it so it will not keep the keys forever. There is two workarounds: disable the Gnome agent and use ssh-agent, or launch a command with screen like: while sleep 1h ; do ssh-add -D ; done – Totor Apr 22 '13 at 21:34

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.