The VNC server needs to know which commands to execute when it starts up. Specifically, VNC needs to know which graphical desktop it should connect to. So lets try to create a new xstartup file - The commands should be located in a configuration file called xstartup in the .vnc folder under your home directory - it is a hidden folder.
Need to be changing how the VNC server is configured, first stop the VNC server instance that is running on port 5901 with the following command:
The output should look like this, although you should see see a different ID#
Output Killing Xtightvnc process ID 18467
Before you modify the xstartup file, back up the original:
Code:
mv ~/.vnc/xstartup ~/.vnc/xstartup.bak
Now create a new xstartup file and open it in your text editor:
Code:
sudo texteditor ~/.vnc/xstartup
- note: where it says texteditor use the one on your system such as nano or mousepad or gedit or whatever you are using
We need VNC to start your desktop environment if it’s not already started. Add these commands to the file: ~/.vnc/xstartup
Code:
#!/bin/bash
xrdb $HOME/.Xresources
startxfce4 &
Save the file. Now, restart the VNC server.
You’ll see output similar to this:
Output New 'X' desktop is your_hostname:1
Starting applications specified in /home/username/.vnc/xstartup
Log file is /home/username/.vnc/your_hostname:1.log
VNC itself doesn’t use secure protocols when connecting. You have to use a SSH tunnel to connect securely to your server. Create an SSH connection on your local computer that securely forwards to the localhost connection for VNC. You can do this via the terminal
Code:
ssh -L 5901:127.0.0.1:5901 -C -N -l username your_server_ip
If you are using a graphical SSH client, like PuTTY, use your_server_ip as the connection IP, and set localhost:5901 as a new forwarded port in the program’s SSH tunnel settings.
Once the tunnel is running, use a VNC client to connect to localhost:5901. You’ll be prompted to authenticate using the password you set.
Once you are connected, you should see the default Xfce desktop. Thats pretty much what I had to do when I botched mine up when I was first playing with VNC and I am still no expert at it