Skip to content

Instantly share code, notes, and snippets.

@surhudm
Last active May 17, 2020 14:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save surhudm/48b79f49d77618d4878408dc97708d65 to your computer and use it in GitHub Desktop.
Save surhudm/48b79f49d77618d4878408dc97708d65 to your computer and use it in GitHub Desktop.
Setup vnc

Setup vnc

Setup ssh

First of all in .ssh/config, create an entry:

host shortnamevnc
    hostname the_url_of_server
    localforward 12345 localhost:5901
    identityfile ~/.ssh/id_rsa
    User change_to_your_username
    
host shortname
    hostname the_url_of_server
    identityfile ~/.ssh/id_rsa
    User change_to_your_username

Run vncserver on the ssh machine

The following commands need to be run everytime the server gets rebooted.

ssh shortname
#On ssh server run vncserver
vncserver -localhost -geometry 1280x800
#Enter some password for vnc, and find out what port the vncserver was started. 
#This info is output at the end after running the command. Look for :1, or :2, 
#call this display number. 
#The number to put instead of 5901 in the .ssh/config file is (5900+display number).

On your local machine

First create the tunnel from the server to your machine

ssh -N shortnamevnc &

This needs to be done everytime the ssh connection gets reset.

For vnc, then run:

vncviewer localhost:12345

or

remmina
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment