Local tunneling question
Andre Charbonneau <[email protected]>
| Newsgroups | gmane.comp.java.sshtools.user |
|---|---|
| Message-ID | <[email protected]> |
Hi,
I'm trying to use the latest release of sshtools to create a local SSH
tunnel to tunnel VNC. (I know the SSHTerm has a VNC feature, but I
would like to use sshtool to simply create a SSH tunnel and then use
another VNC viewer application through this tunnel.)
So I wrote a small java app that simply creates a local forwarding
tunnel, as shown below:
SshClient ssh = null;
ssh = new SshClient();
// Connect and authenticate (GSI)
ssh.connect(connectionProps, new
DialogKnownHostsKeyVerification(null));
SshAuthenticationClient authClient = new GSSAuthenticationClient();
authClient.setHostname(connectionProps.getHost());
authClient.setUsername(""); // Use empty username, GSI will set
the usename to use.
authClient.setProperties(connectionProps);
int result = ssh.authenticate(authClient, connectionProps.getHost());
if(result != AuthenticationProtocolState.COMPLETE)
{
JOptionPane.showMessageDialog(null,
"Authentication error when creating VNC channel.",
"", JOptionPane.WARNING_MESSAGE);
System.exit(1);
}
// Create a tunnel for the VNC traffic.
ForwardingClient forwarding = ssh.getForwardingClient();
forwarding.addLocalForwarding("VNC", "0.0.0.0", 5920,
"localhost", 5920);
forwarding.startLocalForwarding("VNC");
System.out.println("VNC tunnel started.");
// And also open a shell to see what's going on...
SessionChannelClient session=ssh.openSessionChannel();
if (!session.requestPseudoTerminal("vt100",80,24,0,0,""))
System.out.println("Failed to allocate a pseudo terminal");
if (session.startShell())
{
InputStream in=session.getInputStream();
OutputStream out=session.getOutputStream();
IOStreamConnector input=new IOStreamConnector(System.in,out);
IOStreamConnector output=new IOStreamConnector(in,System.out);
output.getState().waitForState(IOStreamConnectorState.CLOSED);
}
My tightvnc server is listening on a.b.c:5920.
If I use the command-line vncviewer to directly access the VNC server
listening on a.b.c:5920, everything works fine. But when I try to use
the tunnel created by the code above (by using the command: xvncviewer
a.b.c::5920), the vncviewer hangs after the password prompt and the only
output log I get on the vnc server side is:
15/05/07 10:53:37 Got connection from client 127.0.0.1
I suspect I'm not setting up the ssh tunnel correctly... Any ideas what
I might be doing wrong?
Any information about this would be much appreciated.
Thanks,
Andre
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/