6

I have opened an ssh tunnel with

ssh -D 8080 -f -C -q -N [email protected]

How can I close it now?

1
  • If you sent that job to the background, can you see it with jobs and then use fg for the number of the job and ^C ?
    – bmike
    Commented Jul 15 at 11:42

4 Answers 4

11

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>

3

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.

1

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

1
  • If the link has relevant information, it should be included in your answer. If the link goes down it devalues your contribution. Commented Jul 15 at 9:42
0

You have to type

~.

to exit/close the ssh connection. I think

exit

also works.

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