{"id":339,"date":"2015-09-09T14:55:31","date_gmt":"2015-09-09T14:55:31","guid":{"rendered":"https:\/\/edulab.unitn.it\/tecnici\/?p=339"},"modified":"2016-06-14T09:55:04","modified_gmt":"2016-06-14T09:55:04","slug":"how-to-install-vnc-server-on-debian-8","status":"publish","type":"post","link":"https:\/\/edulab.unitn.it\/tecnici\/how-to-install-vnc-server-on-debian-8\/","title":{"rendered":"How to install VNC Server on Debian 8"},"content":{"rendered":"<h3>Install VNC Server on Debian<\/h3>\n<p>Very similar to Ubuntu (since Ubuntu is based on Debian), you only need to use vnc4server package to install VNC Server<\/p>\n<pre># apt-get install tightvncserver<\/pre>\n<h3>Configure VNC Server to work on Ubuntu 14.04 \/ Debian 8<\/h3>\n<p>You can use any privileged user or root user to login to your VNC Server, but for security reason, I\u2019m going to create vncuser for my VNC Server (<strong>you can change vncuser in tutorial to any user that you would like to use, it can be your existing user<\/strong>)<\/p>\n<pre># adduser vncuser\r\n# passwd vncuser<\/pre>\n<p>We now switch to vncuser to create some VNC configuration\u2019s files.<\/p>\n<pre># su - vncuser<\/pre>\n<p>With regular or privileged user, start vncserver for vncserver to creates it\u2019s necessary files.<\/p>\n<pre>$ vncserver<\/pre>\n<p>After you started VNC Server, you will be asked to create VNC\u2019s password (VNC password can be different or the same password as your user\u2019s password)<\/p>\n<pre>vncuser@namhuy:~$ vncserver\r\nYou will require a password to access your desktops.\r\nPassword:\r\nVerify:\r\nxauth:\u00a0 file \/home\/vncuser\/.Xauthority does not exist\r\n\u00a0\r\nNew 'namhuy:1 (vncuser)' desktop is namhuy:1\r\n\u00a0\r\nCreating default startup script \/home\/vncuser\/.vnc\/xstartup\r\nStarting applications specified in \/home\/vncuser\/.vnc\/xstartup\r\nLog file is \/home\/vncuser\/.vnc\/namhuy:1.log<\/pre>\n<p>After VNC Server generated files, we have to kill it in order to configure xstartup file.<\/p>\n<pre>$ vncserver -kill :1<\/pre>\n<p>To modify xstartup file<\/p>\n<pre>$ cd ~\r\n$ &gt; .vnc\/xstartup\r\n$ nano .vnc\/xstartup<\/pre>\n<p>With the content<\/p>\n<pre>#!\/bin\/sh\r\nunset SESSION_MANAGER\r\nunset DBUS_SESSION_BUS_ADDRESS\r\n\r\nxrdb $HOME\/.Xresources\r\nxsetroot -solid grey\r\n#x-terminal-emulator -geometry 80x24+10+10 -ls -title \"$VNCDESKTOP Desktop\" &amp;\r\n#x-window-manager &amp;\r\n# Fix to make GNOME work\r\nexport XKL_XMODMAP_DISABLE=1\r\n#\/etc\/X11\/Xsession\r\nxfce4-session &amp;\r\n\r\n\r\n<\/pre>\n<p>If you choose to use other GUIs, replace startxfce4 &amp; accordingly to<\/p>\n<ul>\n<li>Gnome-Desktop Environment: gnome-session &amp;<\/li>\n<li>KDE-Desktop Environment: startkde &amp;<\/li>\n<li>MATE-Desktop Environment: mate-session &amp;<\/li>\n<li>LXDE-Desktop Environment: startlxde &amp;<\/li>\n<li>Cinnamon-Desktop Environment: cinnamon &amp;<\/li>\n<li>Openbox-Desktop Environment: openbox &amp;<\/li>\n<\/ul>\n<p>Save xstartup when you are done. The next step is to create VNC Server statup script. You must do this with root user<\/p>\n<pre>$ su -\r\n# nano\/usr\/local\/bin\/myvncserver<\/pre>\n<p>With the content<\/p>\n<pre>#!\/bin\/bash\r\nPATH=\"$PATH:\/usr\/bin\/\"\r\n#DISPLAY=\"1\"\r\nDISPLAY=\"$1\"\r\nDEPTH=\"16\"\r\n#GEOMETRY=\"1024x768\"\r\nGEOMETRY=\"1280x800\"\r\nOPTIONS=\"-depth ${DEPTH} -geometry ${GEOMETRY} :${DISPLAY}\"\r\n\r\ncase \"$2\" in\r\nstart)\r\n\/usr\/bin\/vncserver ${OPTIONS}\r\n;;\r\n\r\nstop)\r\n\/usr\/bin\/vncserver -kill :${DISPLAY}\r\n;;\r\n\r\nrestart)\r\n$0 stop\r\n$0 start\r\n;;\r\nesac\r\nexit 0\r\n\r\n\r\nNow make vncserver startup script executable<\/pre>\n<pre>#chmod +x \/usr\/local\/bin\/myvncserver<\/pre>\n<p>Script usage:<\/p>\n<pre>sudo \/usr\/local\/bin\/myvncserver  [N] start\r\nsudo \/usr\/local\/bin\/myvncserver [N] stop\r\nsudo \/usr\/local\/bin\/myvncserver [N] restart<\/pre>\n<p>Where [N] in number of Display<\/p>\n<p>The last step is to make VNC Server starts on boot<\/p>\n<pre># nano \/lib\/systemd\/system\/myvncserver.service<\/pre>\n<p>With the content<\/p>\n<pre>[Unit]\r\nDescription=Manage VNC Server on this droplet\r\n\r\n[Service]\r\nType=forking\r\nExecStart=\/usr\/local\/bin\/myvncserver [N] start\r\nExecStop=\/usr\/local\/bin\/myvncserver [N] stop\r\nExecReload=\/usr\/local\/bin\/myvncserver [N] restart\r\nUser=[vncuser]\r\n\r\n[Install]\r\nWantedBy=multi-user.target<\/pre>\n<p>Where [N] in number of Display and [vncuser] is user to start vncserver.<\/p>\n<p>Now we can reload systemctl and enable our service:<\/p>\n<pre># systemctl daemon-reload\r\n# systemctl enable myvncserver.service<\/pre>\n<p>If you want to start \u00a0another vncserver for another\u00a0user add \u00a0myvncserver2.service with differnet \u00a0[N] and [vncuser]\n<p>&nbsp;<\/p>\n<p>Reboot your Debian 8 system and test out your new VNC Server<\/p>\n<pre># reboot<\/pre>\n<p>You can login to your remote server via VNC with domain or IP.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Install VNC Server on Debian Very similar to Ubuntu (since Ubuntu is based on Debian), you only need to use vnc4server package to install VNC Server # apt-get install tightvncserver [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,9],"tags":[],"class_list":["post-339","post","type-post","status-publish","format-standard","hentry","category-how-to","category-linux"],"_links":{"self":[{"href":"https:\/\/edulab.unitn.it\/tecnici\/wp-json\/wp\/v2\/posts\/339","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/edulab.unitn.it\/tecnici\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/edulab.unitn.it\/tecnici\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/edulab.unitn.it\/tecnici\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/edulab.unitn.it\/tecnici\/wp-json\/wp\/v2\/comments?post=339"}],"version-history":[{"count":3,"href":"https:\/\/edulab.unitn.it\/tecnici\/wp-json\/wp\/v2\/posts\/339\/revisions"}],"predecessor-version":[{"id":458,"href":"https:\/\/edulab.unitn.it\/tecnici\/wp-json\/wp\/v2\/posts\/339\/revisions\/458"}],"wp:attachment":[{"href":"https:\/\/edulab.unitn.it\/tecnici\/wp-json\/wp\/v2\/media?parent=339"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/edulab.unitn.it\/tecnici\/wp-json\/wp\/v2\/categories?post=339"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/edulab.unitn.it\/tecnici\/wp-json\/wp\/v2\/tags?post=339"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}