I am trying to connect to my XenServer VM consoles from a PHP/HTML webpage.
The VNC consoles only accept connections from localhost, each console uses a different port (5902,5903,5904,etc..).
Following the instructions outlined in this post
I can connect to the consoles by using Putty to open an SSH tunnel and then forwarding a port (5902 for example). Then I can connect using a VNC client using localhost:5902
.
I am now trying to find a way to do this through a webpage.
If I setup the tunnel through putty on my PC and then use the TightVNC java applet loaded via the website I can connect to the consoles.
- My-PC - 192.168.0.3
- apache - 192.168.0.200
- XenServer - 192.168.0.100
My-PC -> SSH Tunnel -> XenServer
VNC-client(192.168.0.3) -> localhost:5902(Putty tunnel) -> VNC-console(192.168.0.100:5902)
I need a way to do this programmatically.
I have the ssh2 extension installed and have tried like this:
$connection = ssh2_connect("192.168.0.100", 22);
if(ssh2_auth_password($connection, "user", "password"))
{
if ($tunnel = ssh2_tunnel($connection, "127.0.0.1", 5902))
{
echo "Tunnel creation complete.\n";
}else{
echo "Tunnel creation failed.\n";
}
}
else
{
echo "failed!";
}
<applet archive="tightvnc-jviewer.jar"code="com.glavsoft.viewer.Viewer" width="1" height="1">
<param name="Host" value="localhost" />
<param name="Port" value="5902" />
<param name="OpenNewWindow" value="yes" />
<param name="ShowControls" value="yes" />
<param name="ViewOnly" value="no" />
<param name="AllowClipboardTransfer" value="yes" />
<param name="RemoteCharset" value="standard" />
<param name="ShareDesktop" value="yes" />
<param name="AllowCopyRect" value="yes" />
<param name="Encoding" value="Tight" />
<param name="CompressionLevel" value="" />
<param name="JpegImageQuality" value="" />
<param name="LocalPointer" value="On" />
<param name="ConvertToASCII" value="no" />
<param name="colorDepth" value="" />
<param name="ScalingFactor" value="100" />
<param name="AllowAppletInteractiveConnections" value="no" />
</applet>
So my main question is how would I tunnel into these VNC consoles from a webpage using the applet?