Re: Creating dynamic tunnels using bash script (cygwin/solaris)



Hi,

if you can get this to work:

ssh solaris "command to figure out what port you want"
ssh -L5900:localhost:thatport solaris

then perhaps you could prepare a file like this, and give it
execution permissions:

------------------------------------------------------------
#!/bin/bash
port=$( ssh solaris "command to print out the port number (and nothing
else)" )
ssh -L 5900:localhost:$port solaris
------------------------------------------------------------

This would require the user to login twice with his shell user and
pass, and then with his VNC pass, but with a bit more of work you might
turn it into a script that asks for the user and pass and uses them
twice.

Hope it helps:

Wences



galmok@xxxxxxxxx wrote:
Todd H. skrev:
galmok@xxxxxxxxx writes:
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.

Why is that? What is it you're forwarding? Perhaps there's another
way to go about it.

A VNC connection. Considering the user doesn't always know in advance
which port their vnc connection runs on, a script to find their display
has been created. And since it is possible to create port forwarding
dynamically using the escape commands, I wanted to create a
user-friendly way for users to launch a viewer to their vnc session.
Sequence of actions: Double-click icon, enter ssh password, enter vnc
password, ready to use.

Does anyone out there have a suggestion/solution?

The easiest way of course would be

ssh solaris "command to figure out what port you want"
ssh -L5900:localhost:thatport solaris

If typing the password becomes a chore, switch to public key auth and
use ssh-agent first to load your key into memory. After that, ssh
commands to solaris would pop through without a password prompt which
is kinda fun.

Yes, I have setup such a system (ssh-agent) for myself but can't expect
my users to do the same. Also, we have no control over the password (if
any) they chose to put on their local key. If they loose their laptop,
an intruder would have an easy time logging on to our system. And the
user would probably not inform us about the loss of their laptop and if
they ssh key was without a password.

But solaris prevents any stdout being sent back when a tty allocation
is forced. That is a huge showstopper. Also, the local cygwin openssh
client manages to redirect stdin from the pipe to the keyboard when
"~C" is sent via the pipe to ssh, making it difficult to enter
information to create the pipe.

I guess I may be able to use forward a fixed port for a particular user
(making sure each user has their own remote port) and have them make a
tunnel on the remote host to the desired port. Problem is that it
requires double the ports on the server and an tunnel program. It would
be nicer if dynamic port allocation could be programmatically achived
(contrary to interactive only as it is now).

.



Relevant Pages

  • Re: using a remote IMAP server and smarthost
    ... I have set up the alias for ssh, and created a key for authentication. ... You can forward a local port via ssh like this: ... This command establishes an ssh connection to myvm. ...
    (Debian-User)
  • Re: Creating dynamic tunnels using bash script (cygwin/solaris)
    ... I would do something like this (cygwin is my windows box having cygwin ... installed and solaris is a solaris based server): ... My problem is that the destination port is unknown at the time I create ... the ssh call. ...
    (comp.security.ssh)
  • Re: SSH options re: NAT
    ... No, SSH is two-fold, a call to it on the client side results in a call ... port, meaning that any connections that come into that port are answered ... programming practice for daemons) Once the connection is established, ... don't want to execute a command on the remote side and you use -N. ...
    (comp.security.ssh)
  • Re: executing commands from telnet from D3
    ... "Would the ssh command on the remote linux box allow me to get to the ... your user on the linux box would have to first log ... to port 4444/tcp. ...
    (comp.databases.pick)
  • Re: using a remote IMAP server and smarthost
    ... I have set up the alias for ssh, and created a key for authentication. ... You can forward a local port via ssh like this: ... This command establishes an ssh connection to myvm. ...
    (Debian-User)