Creating dynamic tunnels using bash script (cygwin/solaris)
I am trying to create a tunnel via ssh from cygwin to solaris. Normally
I would do something like this (cygwin is my windows box having cygwin
installed and solaris is a solaris based server):
cygwin$ ssh -L5900:localhost:5900 solaris
My problem is that the destination port is unknown at the time I create
the ssh call. Only once I have logged in on solaris can I determine the
destination port. So I was thinking why not use the "~" escape code to
create a tunnel on the fly. The ssh connection is created in a shell
and therefore not used interactively.
So I would do something like this:
(send_commands) | ssh -t -t solaris | (parse_output)
Two problems arise now:
1) Using "-t -t" to force tty allocation prevents anything sent to
stdout/stderr on solaris to be trasmitted to my cygwin box.
2) Sending the escape code "~C" somehow makes ssh grab keyboard input
even though it is placed after a pipe (|), i.e. stdin was supposed to
come from send_commands yet ssh managed to grab keyboard input. I was
quite surprised that this was possible and have still not solved that
puzzle.
Of course, both problems are a showstopper. I dont know why ssh stops
listening to stdin once an escape command is requested "~C" and I am
also at a loss as to why solaris refuses to send any tty output back
via the ssh connection.
Does anyone out there have a suggestion/solution?
|