1

Note: I read and tried the solutions here: How do I remove an SSH forwarded port They did not work for me.

Note: I do not really understand how this works, so extra explanation so that I can learn would be appreciated

I have a docker container running on a remote system where I port map as follows:

docker run --it --rm ... -p abcd:wxyz container:tag

where abcd and wxyz are ports (e.g. 2222:8000)

Then on my local system I would like to listen to the ports at the remote system. I can do this via:

ssh -N -f -L localhost:abcd:localhost:abcd user@host

and like magic things work and I am happy. However, this does not automatically clean up when I am done with it. So I would like to know how to remove the specific listening.

I have tried:

$ ps aux | grep "ssh -N -f -L"
# user 23131   0.0  0.0  4268296    676 s005  S+   11:35AM   0:00.00 grep --color=auto ssh -N -f -L
$ kill 23131
-bash: kill: (23131) - No such process

so that didn't work.

Then I tried many variations of the following and always get:

ssh -O cancel -N -f -L localhost:abcd:localhost:abcd user@host
# No ControlPath specified for "-O" command

So what is the proper way to do this?

SumNeuron
  • 131

1 Answers1

0

First of all I would start looking for your ssh session by just using:

ps aux | grep ssh

as your search didn't find anything (did you put more then one space somewhere?).

For the other command (using -O ssh option) you need control socket. Have a look at -M and -S ssh options and ControlPath and ControlMaster in ssh_config man page.

Tomek
  • 1,288