Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

The following command has been executed on our server, Nexus, to forward remote desktop connections to remote machine Lagos-B:

screen -S rdp
ssh -L [*]:886: root@lagos-b -N

I need to change this bind but I cannot simply overwrite it by entering new command - so how do I remove this existing SSH port forwarder.

Background if needed:

In original setup Nexus would SSH directly into Lagos-B. Lagos-B (a CentOS system) has socat configured to send incoming TCP traffic on port 886 to another machine.

We have changed this and we now have a VPN connection between Nexus and Lagos-B. If I enter the IP address on Nexus into my laptop and unplug the Nexus I can RDP into the remote system without issues. If I try to RDP to Nexus' IP address with the custom port the connection fails.

share|improve this question
Do you mean you want to modify the properties of the existing connection? – Flimzy Jul 3 '11 at 21:10
Yes that would also work for me. I noticed that when I do SSH into Lagos-B and then run netstat on Nexus port 886 is not in use. – Lukasz Jul 3 '11 at 21:37
What do you mean that would also work? If you just don't want port forwarding, remove the -L flag (and its arguments) – Flimzy Jul 3 '11 at 21:48

If you have access to the existing SSH session, you can use OpenSSH's "escape character" to modify your session on-the-fly. When you type "~" plus a character, it escapes the current SSH session, and allows you to execute a command. From the manpage:

     ~#  List forwarded connections.

     ~C  Open command line.  Currently this allows the addition of port
         forwardings using the -L, -R and -D options (see above).  It also
         allows the cancellation of existing remote port-forwardings using
         -KR[bind_address:]port.  !command allows the user to execute a
         local command if the PermitLocalCommand option is enabled in
         ssh_config(5).  Basic help is available, using the -h option.

You can add, change, remove any command line port forwarding magic you've added previously. Look at the manpage for further documentation.

share|improve this answer

Your Answer


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.