Jump to content

Ssh Tunnels


niels

Recommended Posts

Hey,

I have a question about ssh tunnels.

I created a tunnel with this command

ssh -D 8080 -fCqN xxxx@xxx.com -p 3002

now I used the -q option for the tunnel to be quiet.

My question is how can I remove the ssh tunnel I created ?

And second can I list the tunnels that I created or are running ?

Thanks

Niels

Link to comment
Share on other sites

Usually you just type exit or close the program or terminal that you created the tunnel in.

Edited by digip
Link to comment
Share on other sites

Usually you just type exit or close the program or terminal that you created the tunnel in.

I closed the terminal but the tunnel remains running.

I use it to tunnel traffic through firefox to my home network, and I'm still able to connect to a server use the local ip.

So the tunnel is still up and running.

What I mean is how can I disable the tunnel ?

Link to comment
Share on other sites

I closed the terminal but the tunnel remains running.

I use it to tunnel traffic through firefox to my home network, and I'm still able to connect to a server use the local ip.

So the tunnel is still up and running.

What I mean is how can I disable the tunnel ?

Is FF using the ports like a SOCKS proxy? If so, change the settings in FF to not use the tunnel, but you should be able to close it in the terminal via quit or exit. Hell, shut down the SSH service or restart it if you have to, should kill it that way, see what happens.

Link to comment
Share on other sites

Hey,

I have a question about ssh tunnels.

I created a tunnel with this command

ssh -D 8080 -fCqN xxxx@xxx.com -p 3002

now I used the -q option for the tunnel to be quiet.

My question is how can I remove the ssh tunnel I created ?

And second can I list the tunnels that I created or are running ?

Thanks

Niels

Assuming Linux, try using

ps -elf

to list your processes and then use kill with the process id of it. That should get rid of it for you.

Link to comment
Share on other sites

Is FF using the ports like a SOCKS proxy? If so, change the settings in FF to not use the tunnel, but you should be able to close it in the terminal via quit or exit. Hell, shut down the SSH service or restart it if you have to, should kill it that way, see what happens.

Assuming Linux, try using

ps -elf

to list your processes and then use kill with the process id of it. That should get rid of it for you.

Thanks for the response. Yes FF was using a SOCKS proxy, I know I could put it back to auto configuration.

The only problem was taking down the ssh tunnel. But I now managed to do so.

I solved it like this :

1 ps -elf | grep 'ssh'
2 kill ...

so thanls very much for your help this topic is SOLVED

Link to comment
Share on other sites

Ahhh, good deal. See, I was thinking you still had shell access, but I realize now that command just returns you to the prompt once entered. Even if you structure it as

"ssh -D 8080 -fCN -l username site.com -p 3002" which allowed me to logon to my own site, then returned me to the command prompt. Thats my fault for not seeing what the issue was, as I was under the impression it was a normal shell where you could interact with it and type "exit" or "~." to close the session. For this case, I just did a "ps -A" and then "kill -9 PID#" where PID# is the pid number ssh was under.

Edited by digip
Link to comment
Share on other sites

I just did a "ps -A" and then "kill -9 PID#" where PID# is the pid number ssh was under.

Don't use kill -9 as the first try. When you use a -9 on the kill the process doesn't get to finish gracefully (i.e. clear up after itself). Save the -9 for when the process ignores a normal kill.

After all it only takes a process to be killed with -9 while writing data out to a file for it to corrupt the file (e.g. it has updated the header of a file but gets killed with -9 before it writes out the data, leaving you with either just a header in the file or a new header with the old data).

Link to comment
Share on other sites

Don't use kill -9 as the first try. When you use a -9 on the kill the process doesn't get to finish gracefully (i.e. clear up after itself). Save the -9 for when the process ignores a normal kill.

After all it only takes a process to be killed with -9 while writing data out to a file for it to corrupt the file (e.g. it has updated the header of a file but gets killed with -9 before it writes out the data, leaving you with either just a header in the file or a new header with the old data).

And what do you suggest to use in killing the process instead?

Link to comment
Share on other sites

And what do you suggest to use in killing the process instead?

I should probably have worded the first sentence in my last post a bit better, kill on its own without the -9 will normally be enough. If you don't specify a signal then it defaults to the TERM signal (-15). The -9 signal is the KILL signal.

The difference between the two is that the TERM signal is catchable by the process, it can contain it's own signal handler for the TERM signal and when triggered close itself down gracefully. The KILL signal is not catchable by the process, it doesn't get any chance to close down cleanly.

In the case of a grep reading from a file a "kill -9" shouldn't cause any problems, in the case of database a "kill -9" has an increased chance of corrupting data.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...