Unix Shell - ssh via gateway to work host script

This is Interesting: Free IT Magazines  
Home > Archive > Unix Shell > January 2007 > ssh via gateway to work host script





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author ssh via gateway to work host script
mike

2007-01-24, 1:16 pm

Hi,

I am writing a shell script to connect to my work computer.

If I use the following:

ssh -l $USERID -Y -L LOCAL_HOST_PORT:$WORK_HOST:22 $GATEWAY_HOST

I get the following prompt ( of course with real values but just as a
principle).

$USERID@$GATEWAY_HOST's password>

I generate a password and input it at the command line.

Then I have to type on the command line:

ssh -Y -L $WORK_HOST

Is it possible to get this in one script or how can avoid typing the
same information every time I login.

All ideas welcome!

cheers,

//mikael

Allistar

2007-01-25, 1:32 am

mike wrote:

> Hi,
>
> I am writing a shell script to connect to my work computer.
>
> If I use the following:
>
> ssh -l $USERID -Y -L LOCAL_HOST_PORT:$WORK_HOST:22 $GATEWAY_HOST
>
> I get the following prompt ( of course with real values but just as a
> principle).
>
> $USERID@$GATEWAY_HOST's password>
>
> I generate a password and input it at the command line.
>
> Then I have to type on the command line:
>
> ssh -Y -L $WORK_HOST
>
> Is it possible to get this in one script or how can avoid typing the
> same information every time I login.
>
> All ideas welcome!
>
> cheers,
>
> //mikael


When I do this I have the port forward command like this:

ssh -l $USERID -L LOCAL_HOST_PORT:$WORK_HOST:22 $GATEWAY_HOST cat -

always running, then I do a

ssh -p $LOCAL_HOST_PORT $WORK_HOST

It doesn't answer your question, but depending on how often you connect
through the tunnel you could just leave it always open.

There are other ways: use autossh to open a reverse ssh tunnel from
$WORK_HOST to localhost and then connect through that. Beware that some
network administrators may see this as circumventing their firewalls (which
it does).

Allistar.
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com