I want to replace TeamViewer with a FOSS solution. I need to support some remote computers. I have a working SSH tunnel set up between two computers using a middleman server like this:
Kubuntu_laptop--->nat_fw--->Debian_Server<--nat_fw<--Kubuntu_desktop
This SSH tunnel is working now.
Next I want to connect to the desktop on "Kubuntu_desktop" from "Kubuntu_laptop" using the SSH tunnel.
Regarding the connection for this leg:
Debian_Server<--nat_fw<--Kubuntu_desktop
Here is how it is established:
autossh -M 5234 -N -f -R 1234:localhost:22 user@mydebian.com -p 22
I cannot change the existing monitoring port (5234) or the remote (- R) port number (1234 in this example). Can vnc tunnel over this existing SSH connection? UPDATE: the answer is no
; I need to set up a new SSH tunnel for use with vnc as described here.
Regarding the connection for this leg:
Kubuntu_laptop--->nat_fw--->Debian_Server
I can use any SSH parameters required.
I cannot open up any ports on the routers/firewalls.
x11vnc server was recommended to me, so I'm testing with that. It is running on the desktop and listening on port 5900. However, I did not use any command line options when starting x11vnc, so it probably isn't configured correctly yet.
Will vnc work over this existing SSH connection? Notice that there are no ports 5900 defined. And note that I cannot change the port number for the -R option as I mentioned above.
I have a lot of questions about how to get this working, but one is whether vnc can listen on the existing port (-R 1234 in the example above). And if so, can I still ssh into that box as I do now?
Here's what I tried so far:
On remote desktop (where x11vnc server is installed):
tester@Kubuntu_desktop:~> autossh -M 5234 -i ~/.ssh/my_id_rsa -fNR 1234:localhost:5901 user@mydebian.com
make sure x11vnc server is running on port 5901:
tester@Kubuntu_desktop:~> x11vnc -autoport 5901
On my laptop:
sudo ssh -NL 5901:localhost:1234 -i ~/.ssh/admin_id_rsa admin@mydebian.com
connect local vnc client to localhost port 5901
Open KRDC in Kubuntu_laptop and connect to (vnc)
localhost:5901
I'm getting a failed connection - server not found
.
Debian_Server<--nat_fw<--Kubuntu_desktop
is not something I think I can change. (I don't know how.) That leg looks like this:autossh -M <mport> -N -f -R <port>:localhost:<port> user@myserver.com -p <server-port>
– MountainX Jul 09 '13 at 00:05autossh -M 5234 -fNR 1234:localhost:22 user@mydebian.com
toautossh -M 5234 -fNR 1234:localhost:5900 user@mydebian.com
my ssh tunnel is broken. Are you saying that I need two SSH connections? One to be used to connect to a shell onKubuntu_desktop
(using port 22) and the other to connect to vncserver onKubuntu_desktop
(using port 5900)? Sorry I don't understand yet. – MountainX Jul 09 '13 at 05:59x11vnc: The VNC desktop is: Kubuntu_desktop.site:0 PORT=5900
– MountainX Jul 09 '13 at 06:04-fN
from the command. Usually I just open a second connection instead, since closing the shell will close your port forwarding tunnel. – Michael Yasumoto Jul 09 '13 at 17:00lsof -Pi4;
ornetstat -lanpt;
to check this. Also, confirm that your ssh settings allow port forwarding. Check the/etc/ssh/sshd_config
file on the server and make sure thatAllowTcpForwarding yes
andPermitTunnel yes
. Restart your ssh server if you changed the config file. – Michael Yasumoto Jul 09 '13 at 17:07telnet localhost 5900;
to connect to the VNC port and confirm that a connection can be made. From the server, usetelnet localhost 1234;
and confirm the connection. Lastly, from the laptop usetelnet localhost 5900;
. If each segment works, then you should be able to VNC to the localhost of the laptop. – Michael Yasumoto Jul 09 '13 at 17:10