[TriLUG] ssh 'through' a firewall

Mike Johnson mike at enoch.org
Fri Apr 23 22:27:22 EDT 2004


Douglas Kojetin [djkojeti at unity.ncsu.edu] wrote:
> hi all-
> 
> i ssh to a computer computer behind a firewall that has access to other 
> computers behind the network that i frequently need to ssh to.  what i 
> normally do is
> 
> ssh user at firstcomputer
> ssh user at secondcomputer

Write a simple script that does this:
ssh -L 2222:secondcomputer:22 -f user at firstcomputer sleep 60 && \
	ssh -p 2222 user at localhost

Or just make it an alias, or something.

What it does is set up a port forward to the second computer through
port 2222 on localhost.  So, if you connect to port 2222 on localhost,
the packets will be forwarded to port 22 on second computer.  -f says
'go into the background' so that the prompt comes back to you on your
local system, while executing the sleep on the remote host.  This keeps
port 2222 open on localhost for 60 seconds.  If you do not connect to
that port in that time, the port will go away.  If it doesn't take long
to make the connection, shorten that time.

Oh, and I'm assuming that the username is the same on both hosts.

Mike
-- 
"If life hands you lemons, YOU BLOW THOSE LEMONS TO BITS WITH 
 YOUR LASER CANNONS!" -- Brak

GNUPG Key fingerprint = ACD2 2F2F C151 FB35 B3AF  C821 89C4 DF9A 5DDD 95D1
GNUPG Key = http://www.enoch.org/mike/mike.pubkey.asc

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 230 bytes
Desc: not available
URL: <http://www.trilug.org/pipermail/trilug/attachments/20040423/f71b8ea5/attachment.pgp>


More information about the TriLUG mailing list