Skip to main content
1 of 7

Here is a simple example to find PID of ssh-agent for current user without showing PID of grep process itself :

ps xu | grep "${USER}.*[ ]/usr/bin/ssh-agent" | awk '{print $1 $2;}' 

If you want for example to kill ssh-agent for current user you might use following command :

kill `ps xu | grep "${USER}.*[ ]/usr/bin/ssh-agent" | awk '{print $2;}'` 

P.S. I've only tested these commands on Ubuntu