Define key expiration time in OpenSSH authentication agent.
Do not worry as you will be not disconnected from any active SSH session after the identity is removed from an agent. Just note, that by default the key will be kept indefinitely.
-t parameter to define key lifetime during the start of SSH agent.
The following command will store each identity for eight hours (28800 seconds).
$ eval $(ssh-agent -s -t 28800)
You can use seconds by default or specify time qualifier like
S for seconds,
M for minutes,
H for hours,
D for days, and
W for weeks.
So, for example, the following command will store each identity for a single week.
$ eval $(ssh-agent -s -t 1w)
It’s nothing new, but I always try to keep this in mind, so I need to share it here.