I have opened an ssh tunnel with
ssh -D 8080 -f -C -q -N [email protected]
How can I close it now?
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 send a kill signal to the ssh
process once you know the process ID of that tunnel task.
kill -9 $PID
You should search for the ssh
session process ID amongst the others having ssh in it (sshd, pgrep, the tunnel process and perhaps several others.)
pgrep ssh
Choose carefully which process you kill.
use this :
ssh -S /tmp/sshtunnel -O exit server.domain.com -p22
for more check here : link
In the OP’s example, 149.157.140.64 stands in for server.domain.com
You have to type
~.
to exit/close the ssh connection. I think
exit
also works.
jobs
and then usefg
for the number of the job and ^C ?