SSH tunneling and teardown of session

amrogers3

Gawd
Joined
Nov 7, 2010
Messages
644
EDIT: I am running OSX Leopard 10.5 and DDWRT is running on WRT54GL v24-sp2 (08/12/10) vpn

I have an SSH tunnel set up using DDWRT. So now I can surf securely when I am in a remote location.

The problem is after I am done browsing, I can't figure out how to close out the session in a proper manner. For example, I type

ssh -p 2222 -N -D 8888 [email protected]

and it works with no problems. However, to kill the session I have to hit "CTR" and "Z". This is not the best solution because it leaves the session and port still open.


"ps aux | grep ssh" shows:

test 11050 0.0 0.1 600120 1364 s000 S 2:09PM 0:05.66 ssh -p 2222 -N -D 8888 [email protected]

netstat -an | grep '8888'

tcp4 0 0 127.0.0.1.8888 *.* LISTEN


Any suggestions on how to tear down the session without using "ps aux" and then the "kill" command?
 
If you do not use the -N option, you'll get an interactive shell. Then you can just hit ctrl-D or type 'exit' to end the tunnel.

Or you can do 'kill 11050' (the first number in what you grep'd earlier is the PID) and it will end it.

If you do 'ps ax | grep sh' it won't show your grep command in the process list.
 
However, to kill the session I have to hit "CTR" and "Z". This is not the best solution because it leaves the session and port still open.

control-z is used to suspend processes. control-c will kill it.
 
If you do not use the -N option, you'll get an interactive shell. Then you can just hit ctrl-D or type 'exit' to end the tunnel.

Or you can do 'kill 11050' (the first number in what you grep'd earlier is the PID) and it will end it.

If you do 'ps ax | grep sh' it won't show your grep command in the process list.


Thanks for reply robvas. I didn't want to have to fidn the connection and then kill the process. I was looking for a more eloquent solution.

control-z is used to suspend processes. control-c will kill it.

Do you know if that works for OSX? If I remember correctly, I tried CTRL C and it didn't work. Anyway, I can try when I get home and see what happens. Thanks.
 
Back
Top