I have opened an ssh tunnel with lucas-MacBook-Pro:~ donbeo$ ssh -D 8080 -f -C -q -N [email protected]

How can I close it now?

3 Answers 3


Find the ssh tunnel's process id running on a specific port:

ps aux | grep <port number>

and kill the process:

kill -9 <process id>


You can kill the ssh process like others with

kill -9 $PID

You can find ssh session process ID with

pgrep ssh

You have to type


to exit/close the ssh connection. I think


also works.

  • can you post the full command? The connection is working in background
    – Donbeo
    Oct 15, 2015 at 14:36
  • Ah sorry, background process... So you have to check for the pid and use 'kill -9 id'.
    – matthias
    Oct 15, 2015 at 14:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .