On Wed, May 22, 2013 at 08:15:24AM -0500, Nelson Green wrote: > Hello all, > > Seems I'm a bit brain dead this morning, and I'm having difficulty > remembering how to set up an ssh tunnel to our development server through > the public facing system > > I can ssh into pub1 just fine, and from that shell I can ssh into the > development server, dev1. What I want to do is to be able to open a > terminal on my local machine and connect my psql client directly to that > development server, on it's port 5432. So I want to be able to locally run > a command similar to: > [me@mymachine]$ psql -U dbusername -h dev1 -p xxx > where, if I remember correctly, xxx is the port I tunnel into the public > system on. > > I know I've done this before, but since I rarely work from home like this > I've forgotten the steps. Would someone care to enlighten me? I'm not sure you can do exactly what you want, but it you issue: [me@machine]$ ssh my@pub1 -L5432:dev1:5432 then, assuming that pub1 can access port 5432 on dev1, you can do [me@mymachine]$ psql -U dbusername -h localhost p 5432 So your SSH client listens on localhost:5432 and pub1 connects to dev1:5432. If you can only access dev1 by ssh and need a second hop, thinks get more difficult :) > > On a related note, how do I kill the tunnel after I am done with it. I've > just killed the process in the past, but I'm wondering if there is not a > more elegant way? If you close the SSH session, it'll take the tunnel down with it.
Attachment:
signature.asc
Description: Digital signature