How do I remove an SSH forwarded port
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Over a Mysterious Island
--
Chapters
00:00 How Do I Remove An Ssh Forwarded Port
00:13 Accepted Answer Score 98
00:31 Answer 2 Score 13
00:46 Answer 3 Score 18
01:39 Answer 4 Score 32
01:58 Thank you
--
Full question
https://superuser.com/questions/87014/ho...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#ssh #portforwarding
#avk47
ACCEPTED ANSWER
Score 98
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>
ANSWER 2
Score 32
How to cancel a forwarded port in an already running SSH session:
- Press ~+C (tilde + capital C)
- Type
-KL 10002
(or whatever port number) - Press Enter
You should see this:
ssh> -KL 10002
Canceled forwarding.
ANSWER 3
Score 18
You can enter an interactive console by typing ~C (capital "C"). This lets you dynamically add and remove port forwardings (among a few other things).
This sequence has to come right after a carriage return/newline. So in doubt, just type Enter~C (in sequence).
If you don't see the characters appear on the console, you're doing it right :)
You should now see an ssh>
prompt.
To remove the port, simply enter -KL 10002
followed by Enter (where 10002
is your forwarded port).
The inverse - adding a new forward - can be done like this (from start to finish):
Enter~C
ssh> -L 10002:192.168.0.30:10002
Enter
ANSWER 4
Score 13
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.