When working with git and a server via SSH, there’s a common headache: ssh-agent
(or other processes) keep running in the background, even after you exit the console with exit
. This leads to dozens of ssh-agent
processes piling up… and most hosting providers have strict limits on the number of active processes. Not to mention, they just waste resources for no reason. And we’re all for efficiency, right?
So, here’s a quick recipe on how to automatically terminate ssh-agent
on exit to avoid errors like:
error: cannot create thread: Resource temporarily unavailable
fatal: send-pack: unable to fork off sideband demultiplexer
-bash: fork: retry: Resource temporarily unavailable
-bash: fork: Resource temporarily unavailable