Re: Initiate SSH session from other side?
- From: Andrew Schulman <andrex@xxxxxxxxxxxx>
- Date: Mon, 14 Aug 2006 16:16:56 GMT
"dspfun" <dspfun@xxxxxxxxxxx> writes:
Is it possible to somehow trigger an SSH session from inside a network,
so that I can use an SSH session from outside the network into the
network? For example by having a program (crontab) or something
initiating the SSH session from inside the network to a specific
IP-address and port number? The problem is that it is not possible to
directly ssh into the network from outside the network.
I believe you could setup an ssh session from inside to outside
machine. As part of that session, try including port forwarding, of
say port 6666 of the outside box to the inside box port 22. See the
man page for ssh and look at the -R option.
insidebox$ ssh -R6666:127.0.0.1:22 outsideusername@xxxxxxxxxxxxxxxxxx
This will forward all traffic hitting outsidebox port 6666 to port 22
of the insidebox.
Then, if you have an ssh server setup on the inside box,
outsidebox$ ssh -p 6666 insideboxusername@xxxxxxxxx
I think would get you where you want to go.
Yup, all correct. The only remaining problem is what to do when the ssh
connection goes down, as they often do. You want the client to reestablish
the connection automatically. The tool for that is autossh:
http://www.harding.motd.ca/autossh/ . autossh starts an ssh session, then
periodically sends data through a loop of port forwardings over the ssh
tunnel. If the data doesn't come back, it concludes that the session is
dead, kills it, and starts a new one.
I have autossh installed as a service under Cygwin. It starts at boot, and
sets up port forwardings, both from inside to out (-L) and from outside to
in (-R). Now that it's set up I don't have to think about it at all; the
port forwardings are just there, all the time. I'm using one right now to
read and reply to your message.
Of course a setup of that kind requires an unattended login on the server.
Unattended logins bring risks, but the risks can be minimized. The snail
book chapter 11 talks about it.
Good luck,
Andrew.
--
To reply by email, change "deadspam.com" to "alumni.utexas.net"
.
- Follow-Ups:
- Re: Initiate SSH session from other side?
- From: dspfun
- Re: Initiate SSH session from other side?
- References:
- Initiate SSH session from other side?
- From: dspfun
- Re: Initiate SSH session from other side?
- From: Todd H.
- Initiate SSH session from other side?
- Prev by Date: Re: Benefits of VNC over RDP
- Next by Date: AllowUsers and AllowHosts
- Previous by thread: Re: Initiate SSH session from other side?
- Next by thread: Re: Initiate SSH session from other side?
- Index(es):
Relevant Pages
|
|