VNC is a protocol that allows a desktop to be viewed and controlled remotely over the Internet.
This is how to create VNC tunnel via SSH.
Requirements:
- Ubuntu system (as VNC Server)
- Windows system (as VNC Viewer)
- PuTTY for Windows
- TightVNC Viewer or RealVNC for Windows
In Ubuntu PC, install x11vnc and openssh-server:
$ sudo apt-get install x11vnc openssh-server
Make sure your firewall allowed incoming connection on port 22.
In Windows PC, download and install: PuTTY, TightVNC / RealVNC.
Run PuTTY and go to PuTTY configuration window: Connection > SSH > Tunnels.
In Tunnels section of PuTTy, type 5902 for Source port, and type localhost:5900 for Destination, then click Add.
Go back to Session section of PuTTY, type Ubuntu IP Address for Host Name (or IP address) , and type 22 for Port, then click Open.
Type in Ubuntu login name and password in PuTTY window, and then type the following line in Ubuntu shell:
$ x11vnc -safer -localhost -nopw -once -display :0
Make sure there is no error message when you run the above command.
Now leave the PuTTY window, then run TightVNC / RealVNC Viewer.
Type localhost::5902 for VNC server and press Connect.
Finish. Now you can access Ubuntu PC remotely via SSH.
resubmitted with an attempt at using markup; I hope this looks better.
I am running ubuntu 20.04.3 on a RasPi 4B I have installed MATE desktop (desktopify) using lightdm. I have installed x11vnc. With the firewall down on the linux box my windows box can login using VNC Connect by RealVNC using the Ipaddress and port 5900 (insecure no encryption). I enable UFW with port 22 open on the linux box. Putty can still login the linux box using ipaddress, 22. So I have the port open. When I try logging into putty as an ssh tunnel things get tricky. The ssh tunnel login seems to work. Then I enter the command ‘x11vnc -safer -localhost -nopw -once -display :0’ I get the following:
“`ubuntu@ubuntu:~$ x11vnc -safer -localhost -nopw -once -display :0
09/12/2021 12:14:26 -safer mode:
09/12/2021 12:14:26 vnc_connect=0
09/12/2021 12:14:26 accept_remote_cmds=0
09/12/2021 12:14:26 safe_remote_only=1
09/12/2021 12:14:26 launch_gui=0
09/12/2021 12:14:26 x11vnc version: 0.9.16 lastmod: 2019-01-05 pid: 3203
Invalid MIT-MAGIC-COOKIE-1 key09/12/2021 12:14:26 XOpenDisplay(“:0”) failed.
09/12/2021 12:14:26 Trying again with XAUTHLOCALHOSTNAME=localhost …
Invalid MIT-MAGIC-COOKIE-1 key
09/12/2021 12:14:26 ***************************************
09/12/2021 12:14:26 *** XOpenDisplay failed (:0)
“`
here is a couple of commands where the output may help:
“`
ubuntu@ubuntu:~$
ubuntu@ubuntu:~$ echo “$DISPLAY”
ubuntu@ubuntu:~$ echo “$XAUTHLOCALHOSTNAME”
“`
Can you help?
Please check https://stackoverflow.com/questions/13301494/remotely-start-session-on-display-0
Thanks