Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I used ssh -L 10002:192.168.0.30:10002 192.168.1.135 to establish port forwarding but now I need to remove it.

How do I do this?

share|improve this question

2 Answers 2

up vote 9 down vote accepted

If you are using Linux you can kill the process by:

ps aux | grep ssh

and then use

kill <id>

To kill the process.

If the kill command is not successfull you can try

kill -9 <id>
share|improve this answer
17  
No. No. No. Please, please, please do not use kill -9 until after you've tried just kill. Many processes will have signal handlers which will clean up their use of resources, cleanly close connections and other pre-shutdown tasks. If you kill with -9, the process dies immediately without doing the cleanup. Killing without -9 will work most of the time. –  Doug Harris Dec 23 '09 at 18:44
6  
kill -9 without reason is like using a shotgun to kill a mosquito. :) –  Darren Hall Dec 23 '09 at 21:24

You could use the "escape-key" (usually ~) followed by C to get a cli to your connection. You can from there remove tunnels without taking down your connection.

share|improve this answer
    
I'd like to know the specifics of this. I know you can add tunnels after you've SSH'd in, but have yet to find out how to take one down. –  carestad Nov 24 at 22:40
1  
When you are in CLI mode you could do help. -KL is the oppsite of -L, -KR is the oppsite of -R and -KD is the oppsite of -D. Doing "escape-key" (~) followed by # shows your tunnels. –  Jimmy Hedman Nov 28 at 11:02

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.