{"id":32,"date":"2013-04-16T15:54:30","date_gmt":"2013-04-16T22:54:30","guid":{"rendered":"http:\/\/inbaudwetrust.com\/?p=32"},"modified":"2013-04-16T15:54:30","modified_gmt":"2013-04-16T22:54:30","slug":"how-to-use-ssh-tunnelling-for-a-vnc-connection-to-launch-a-gnome-desktop","status":"publish","type":"post","link":"https:\/\/inbaudwetrust.com\/wp\/?p=32","title":{"rendered":"How to SSH tunnel a VNC connection and launch a Gnome desktop"},"content":{"rendered":"<p>For remote graphical access to a linux server I generally prefer to use <a title=\"FreeNX\" href=\"https:\/\/www.google.com\/url?sa=t&amp;rct=j&amp;q=&amp;esrc=s&amp;source=web&amp;cd=1&amp;cad=rja&amp;ved=0CDIQFjAA&amp;url=http%3A%2F%2Ffreenx.berlios.de%2F&amp;ei=5NRtUZDgD8jMyQG4xoDoDg&amp;usg=AFQjCNHrVhiiKIAf_8gjKnwOiZqnzgiXZQ&amp;sig2=sEOlaTi25PmWw0CN_Ugbtw&amp;bvm=bv.45218183,d.aWc\" target=\"_blank\">NX aka nomachine<\/a>, however I&#8217;ve been doing admin work on some shared servers that I don&#8217;t want to install NX on for a few different reasons. \u00a0All of the other admins here use VNC with SSH tunneling to access these boxen so I figured I would toe the party line and use VNC as well. \u00a0Here&#8217;s a quick guide as to what I did in order to get VNC with SSH tunneling working, complete with accessing a gnome desktop.<\/p>\n<p>I am using Putty for SSH on Windows, and a TightVNC client to access a CentOS 6.x box that is running a Gnome desktop.<\/p>\n<h3>Putty Setup<\/h3>\n<p>In the putty session for the host you are connecting to, go to SSH &#8211;&gt; Tunnels and set the port that you are going to forward. \u00a0VNC ports start @ 5900 by default and vary depending on the session number you choose. \u00a0In my example we&#8217;re going to use session number 66, so we&#8217;re going to forward port 5966 to localhost:5966 and click add, then save the configuration.<\/p>\n<p><a href=\"http:\/\/inbaudwetrust.com\/wp-content\/uploads\/2013\/04\/vnc5966.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignleft size-full wp-image-34\" alt=\"vnc5966\" src=\"http:\/\/inbaudwetrust.com\/wp-content\/uploads\/2013\/04\/vnc5966.jpg\" width=\"456\" height=\"444\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<h4>VNC Server Configuration<\/h4>\n<p>In this section we&#8217;re going to configure the VNC server, define ~\/.vnc\/xstartup to launch Gnome when your VNC session is started and actually launch a VNC session to connect to.<\/p>\n<p>SSH to the vncserver using the session with the tunnel defined from the last step. \u00a0Once you&#8217;re there create ~\/.vnc\/xstartup if it is not already defined and replace the contents with the following:<\/p>\n<pre><em>[ -x \/etc\/vnc\/xstartup ] &amp;&amp; exec \/etc\/vnc\/xstartup<\/em>\n<em>[ -r $HOME\/.Xresources ] &amp;&amp; xrdb $HOME\/.Xresources<\/em>\n<em>xsetroot -solid grey<\/em>\n<em>vncconfig -iconic &amp;<\/em>\n<em>\/usr\/bin\/gnome-session &amp; gnome-terminal &amp;<\/em><\/pre>\n<p>Mainly what we&#8217;re looking for here is the last line, which tells X to launch a gnome session when a new VNC session is created. \u00a0In this example I also have it launching gnome-terminal, so you can see how you could launch multiple apps every time a session is initiated. \u00a0You could add whatever apps you want to this, such as firefox or eclipse. \u00a0When you&#8217;re done editing the file, make sure it is executable by doing a chmod +x.<\/p>\n<p>Finally, we&#8217;re going to launch a vnc session \u00a0and then connect to it with tightvnc. \u00a0If this is your first time launching a VNC session then it will ask you to define a password to secure your current and future sessions. \u00a0Here, :66 defines the session number.<\/p>\n<pre><em>$vncserver :66<\/em><\/pre>\n<p>It is important that your session number match the port that is forwarded&#8230; vncserver :10 would launch a session on port 5910, vncserver :22 would launch a session on port 5922. \u00a0<em>Whatever session number\/corresponding port is launched has to be defined as a tunnel in putty.<\/em><\/p>\n<p>Now that the session is launched, we just open TightVNC(or your favorite VNC client) and connect it to localhost:66 (session number), enter the VNC password that you defined and voila!<\/p>\n<p><a href=\"http:\/\/inbaudwetrust.com\/wp-content\/uploads\/2013\/04\/tvnc.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignleft size-full wp-image-35\" alt=\"tvnc\" src=\"http:\/\/inbaudwetrust.com\/wp-content\/uploads\/2013\/04\/tvnc.jpg\" width=\"423\" height=\"120\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>That&#8217;s it! \u00a0we now have our connection to our Linux server with Gnome launched!<\/p>\n<p><a href=\"http:\/\/inbaudwetrust.com\/wp-content\/uploads\/2013\/04\/vncdone.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignleft size-medium wp-image-36\" alt=\"vncdone\" src=\"http:\/\/inbaudwetrust.com\/wp-content\/uploads\/2013\/04\/vncdone-300x211.jpg\" width=\"300\" height=\"211\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>-bb<\/p>\n","protected":false},"excerpt":{"rendered":"<p>For remote graphical access to a linux server I generally prefer to use NX aka nomachine, however I&#8217;ve been doing admin work on some shared servers that I don&#8217;t want to install NX on for a few different reasons. \u00a0All of the other admins here use VNC with SSH tunneling to access these boxen so&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7,3],"tags":[19,23,33,38,39],"class_list":["post-32","post","type-post","status-publish","format-standard","hentry","category-linux","category-tech","tag-gnome","tag-linux","tag-putty","tag-ssh-tunnel","tag-vnc"],"_links":{"self":[{"href":"https:\/\/inbaudwetrust.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/32","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/inbaudwetrust.com\/wp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/inbaudwetrust.com\/wp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/inbaudwetrust.com\/wp\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/inbaudwetrust.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=32"}],"version-history":[{"count":0,"href":"https:\/\/inbaudwetrust.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/32\/revisions"}],"wp:attachment":[{"href":"https:\/\/inbaudwetrust.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=32"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/inbaudwetrust.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=32"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/inbaudwetrust.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=32"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}