Silly SSH question

Gregory Boyce gboyce at badbelly.com
Sat Apr 2 14:32:50 EST 2005


On Sat, 2005-04-02 at 13:36 -0500, Josh Pollak wrote:
> I've got a silly question about ssh. I've been using the following line 
> to open up a port forwarding tunnel:
> 
> ssh -L7000:hostname:80 -f -N uname at hostname
> 
> -N tells SSH not to execute a command (so I don't get a shell), and -f 
> says to drop into the background as soon as its authenticated, which 
> allows me to type my password and not have to type ctrl-z, 'bg'.
> 
> The question is, how do I cleanly kill this tunnel? I've been running 
> 'ps aux | grep ssh', finding the line and killing it, but that seems 
> kludgy. Is there a 'right way' to do this? Even just having ssh return 
> or save its pid somewhere?

What I generally do instead of using -f is to just run the ssh command
within screen, and then disconnect from screen.  It is then out of my
way, and I can use screen -r to access the process in order to kill it
(or reconnect) as needed.

Not sure if you'd consider that better or worse than your current
solution though :)




More information about the Discuss mailing list