Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

To access restricted university web pages I often run the following command:

ssh -fND port username@uni.address.here

Then I open a firefox profile which I have set to go through port 5555 using a socks proxy. I have been doing this using cygwin ssh for a while and it works fine. Now I'm running it on ubuntu and it works too however it doesn't seem to end when I close the terminal. I currently have no terminals open but I can still browse the web using a socks proxy on port 5555 and access all the restricted pages that I shouldn't be able to. If I change the port number or firefox profile then I can't access those files so the only conclusion I can come to is that the connection is still open which leads to my question: How do I cancel this?

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

The ssh process must still be running. If you know for sure that this is the only ssh process running as your user, you can do

killall ssh

as your user. However, it is much safer to find the right process PID and kill that specific process - this avoids killing any other ssh processes that happen to be running. You can either do that with a graphical tool, or:

ps -Afl|grep ssh

this will give you a list of processes - the first number after the username on each line is the PID. Then kill it:

kill PID

where PID is the PID you found above.

Edit by asker:

Instead of killing the process manually whenever I do this I made a shell file that someone else might find useful:

ssh -fND port user@uni.address.here && firefox -P SSH && kill `ps -ef|grep "ssh -fND"|grep -v "grep"|cut -c10-15`

The firefox command opens firefox with the SSH profile, which I had to create (it just has the necessary proxy settings). The second grep on the processes is just to avoid kill the grep process itself (though thinking about it now that doesn't seem necessary: grep will be finished by the time it will be killed).

share|improve this answer
    
I tried something but just couldn't find the right process, thanks for the help it fixed it. But can you explain why it doesn't stop when I exit the terminal? Is there something I can do to stop this instead of looking up the PID every time? Thanks –  Paul Apr 24 '11 at 15:29
    
The terminal must be sending a different kill signal to the ssh process - or even no signal at all! I know how to do the reverse (make processes ignore signals) but this is strange. Which terminal app are you using? Gnome terminal? xterm? –  Robin Green Apr 24 '11 at 15:33
    
Just the standard gnome terminal - freshly installed today. –  Paul Apr 24 '11 at 15:35
    
Looks like this bug was fixed back in Jaunty Jackalope. Which version of Ubuntu are you using? –  Robin Green Apr 24 '11 at 15:38
    
Downloaded it just the other day. It's lucid lynx : 10.04 LTS –  Paul Apr 24 '11 at 15:40
show 3 more comments

Your Answer

 
discard

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.