<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="/stylesheets/rss.css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>vamp: dm: Remote Control of OS X (Tiger) Desktop via VNC</title>
    <link>http://www.dminor.com/blog/articles/2007/12/21/remote-control-of-os-x-tiger-desktop-via-vnc</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>variations on a short vamp in d minor</description>
    <item>
      <title>Remote Control of OS X (Tiger) Desktop via VNC</title>
      <description>&lt;p&gt;I&amp;#8217;ve been asked to post the method that I use to easily log onto remote macs to facilitate support on some of my client&amp;#8217;s machines.  This is not rocket science, just my howto that I pieced together from several sources long forgotten (sorry).  It&amp;#8217;s very possible that this procedure will continue to work on Leopard, all of the machines I deal with are still running Tiger at this point.  I think this worked with Jaguar too, but I can&amp;#8217;t recall.&lt;/p&gt;


	&lt;p&gt;The basic idea is to log onto the remote machine via &lt;span class="caps"&gt;SSH&lt;/span&gt;, start a &lt;span class="caps"&gt;VNC&lt;/span&gt; server, then connect from the local machine and use &lt;span class="caps"&gt;SSH&lt;/span&gt; port forwarding tricks to keep yourself from leaving &lt;span class="caps"&gt;VNC&lt;/span&gt; ports open and forwarded on the remote router.&lt;/p&gt;


	&lt;h3&gt;Remote Machine Setup&lt;/h3&gt;


	&lt;ul&gt;
	&lt;li&gt;must have an administrator&amp;#8217;s account&lt;/li&gt;
		&lt;li&gt;must have a static IP address on the &lt;span class="caps"&gt;LAN&lt;/span&gt;&lt;/li&gt;
		&lt;li&gt;install &lt;a href="http://www.redstonesoftware.com/osxvnc"&gt;OSXvnc&lt;/a&gt; which is now called something else.  I am running version 1.4.  I&amp;#8217;m not sure if this will work with the new server&lt;/li&gt;
		&lt;li&gt;create a ~/bin directory&lt;/li&gt;
		&lt;li&gt;in ~/bin, I have two files:&lt;/li&gt;
	&lt;/ul&gt;


&lt;blockquote&gt;&lt;code&gt;&lt;pre&gt;dminor$ cat bin/startvnc 
#!/bin/sh
sudo /Applications/OSXvnc.app/OSXvnc-server -rfbport 5900 \
&amp;gt; ~/Library/Logs/OSXvnc-server.log 2&amp;gt;&amp;#38;1 &amp;#38;

echo "VNC has started" 

dminor$ cat bin/stopvnc 
#!/bin/sh

sudo killall OSXvnc-server
echo "VNC has stopped" 
&lt;/pre&gt;&lt;/code&gt;&lt;/blockquote&gt;

	&lt;ul&gt;
	&lt;li&gt;locally, run bin/startvnc and bin/stopvnc to make sure they are working properly and that they are firing off the osxvnc server&lt;/li&gt;
		&lt;li&gt;in ~/.bash_profile, just under my path, I put &lt;code&gt;source ~/bin/startvnc&lt;/code&gt; and as the last line of the file, &lt;code&gt;trap '$HOME/bin/stopvnc' 0&lt;/code&gt;&lt;/li&gt;
		&lt;li&gt;now when you start a terminal sesssion (locally or &lt;span class="caps"&gt;SSH&lt;/span&gt;), the vnc server will start.&lt;/li&gt;
		&lt;li&gt;verify in Sharing Pref Pane that the &lt;em&gt;Remote Login&lt;/em&gt; service is checked and that you can &lt;span class="caps"&gt;SSH&lt;/span&gt; into the box.&lt;/li&gt;
	&lt;/ul&gt;


	&lt;h3&gt;Remote Network Setup&lt;/h3&gt;


	&lt;p&gt;You&amp;#8217;ll need to have port forwarding on the network&amp;#8217;s router to the remote machine on port 22.  As you&amp;#8217;ll see below, there is no need to have &lt;span class="caps"&gt;VNC&lt;/span&gt; ports forwarded on the router.&lt;/p&gt;


	&lt;h3&gt;Ease of Access via Hostname&lt;/h3&gt;


	&lt;p&gt;It sure makes it a lot easier if you can &lt;span class="caps"&gt;SSH&lt;/span&gt; to a hostname that stays constant instead of having to determine the dynamic IP address of the remote machine each time.  For dynamic IPs, I use dyndns.org to maintain a good hostname.  For static IPs, I just setup an A record in the &lt;span class="caps"&gt;DNS&lt;/span&gt; zone file.  Actually, if it&amp;#8217;s a dynamic, I usually setup a &lt;span class="caps"&gt;CNAME&lt;/span&gt; record pointing to the dyndns hostname.  And this works great on a local network too with bonjour.&lt;/p&gt;


	&lt;h3&gt;Local Machine Setup&lt;/h3&gt;


	&lt;p&gt;On your local machine, you need &lt;span class="caps"&gt;SSH&lt;/span&gt; and a &lt;span class="caps"&gt;VNC&lt;/span&gt; client.  On &lt;span class="caps"&gt;OSX&lt;/span&gt;, I use &lt;a href="http://cotvnc.sourceforge.net"&gt;Chicken of the &lt;span class="caps"&gt;VNC&lt;/span&gt;&lt;/a&gt;.&lt;/p&gt;


In my ~/.ssh/config file, I&amp;#8217;ve setup entries for each remote machine like:
&lt;blockquote&gt;&lt;code&gt;&lt;pre&gt;
Host jkmini
  HostName jkwork.clients-domain.com
  Port 22
  Compression yes
  LocalForward 5901 127.0.0.1:5901
&lt;/pre&gt;&lt;/code&gt;&lt;/blockquote&gt;

Now when &lt;span class="caps"&gt;I SSH&lt;/span&gt; jkmini, I get a terminal and vnc starts automatically.  Here&amp;#8217;s a sample session on the local network:
&lt;blockquote&gt;&lt;code&gt;&lt;pre&gt;
[dminor@ginger: ~]$ ssh sarahs-imac.local
Last login: Fri Dec 21 15:54:35 2007 from ginger.local
Welcome to Darwin!
VNC has started

[dminor@Sarahs-iMac: ~]$ ps aux | grep vnc
root     21718   0.0  0.2   196736   2680  p2  S     3:55PM   0:00.17 /Applications/OSXvnc.app/OSXvnc-server -rfbport 5900
dminor   21721   0.0  0.0    27812      4  p2  R+    3:55PM   0:00.00 grep vnc

[dminor@Sarahs-iMac: ~]$ logout
VNC has stopped
Connection to sarahs-imac.local closed.
&lt;/pre&gt;&lt;/code&gt;&lt;/blockquote&gt;

	&lt;p&gt;In the case of a controlling a local machine (as above), I&amp;#8217;d simply fire up &lt;em&gt;Chicken of the &lt;span class="caps"&gt;VNC&lt;/span&gt;&lt;/em&gt; and connect to the hostname.local on the proper port (5900 here) and gain access.&lt;/p&gt;


	&lt;p&gt;On a remote session over &lt;span class="caps"&gt;SSH&lt;/span&gt;, you&amp;#8217;ll see that we setup local port forwarding on the &lt;span class="caps"&gt;SSH&lt;/span&gt; session, so locally, port 5901 is being redirected to 5901 on the remote machine over &lt;span class="caps"&gt;SSH&lt;/span&gt;.  I fire up Chicken and connect to &lt;strong&gt;localhost:5901&lt;/strong&gt;.&lt;/p&gt;


	&lt;h3&gt;Multiple Remote Machines That Share a &lt;span class="caps"&gt;LAN&lt;/span&gt;&lt;/h3&gt;


	&lt;p&gt;I&amp;#8217;ve also configured multiple machines behind the same router (therefore a shared public IP).  I can attach to two machines on the same &lt;span class="caps"&gt;LAN&lt;/span&gt; at the same time over &lt;span class="caps"&gt;SSH&lt;/span&gt; with no problems.  I may post that additional writeup one day.&lt;/p&gt;


	&lt;p&gt;I hope this is helpful and not too confusing.&lt;/p&gt;</description>
      <pubDate>Fri, 21 Dec 2007 15:25:00 -0600</pubDate>
      <guid isPermaLink="false">urn:uuid:fcb86f44-ec6e-45df-ab3a-396165462596</guid>
      <author>Dave Minor</author>
      <link>http://www.dminor.com/blog/articles/2007/12/21/remote-control-of-os-x-tiger-desktop-via-vnc</link>
      <category>Mac OS X</category>
      <category>Server</category>
      <category>Hardware</category>
    </item>
    <item>
      <title>"Remote Control of OS X (Tiger) Desktop via VNC" by Dave</title>
      <description>Bingo.  The other trick is you'll need a separate ~/.ssh/custom_known_hosts file for each additional machine so that you don't have hostname clash.  This is taken care of with the UserKnownHostsFile directive in ~/.ssh/config.  

You also need a different port forwarding setup in your ssh/config.  The second machine looks like:
&lt;code&gt;&lt;pre&gt;
Host jkminifd
  HostName jkwork.clients-domain.com
  Port 2222
  UserKnownHostsFile ~/.ssh/mini_known_hosts
  Compression yes
  LocalForward 5902 127.0.0.1:5901 

&lt;/pre&gt;&lt;/code&gt;

note the LocalForward from 5902 locally to 5901 remotely.  The in the VNC client, I know that to connect to this machine after getting SSH working, I connect to localhost:5902.  

I keep track of the remote machines via shortcuts in the VNC client.</description>
      <pubDate>Fri, 21 Dec 2007 20:55:05 -0600</pubDate>
      <guid isPermaLink="false">urn:uuid:86795a03-33d2-4ed7-b297-9db95cb71e0d</guid>
      <link>http://www.dminor.com/blog/articles/2007/12/21/remote-control-of-os-x-tiger-desktop-via-vnc#comment-354</link>
    </item>
    <item>
      <title>"Remote Control of OS X (Tiger) Desktop via VNC" by doug</title>
      <description>I guess with multiple machines behind the firewall you'd just forward some port other than 22 on the firewall to port 22 on the Mac behind the firewall.  Then setup a ~/.ssh/config setting for that specific port.

Thanks for posting this...</description>
      <pubDate>Fri, 21 Dec 2007 17:16:17 -0600</pubDate>
      <guid isPermaLink="false">urn:uuid:482acc9e-1850-45c5-a3a2-2ce40f416d52</guid>
      <link>http://www.dminor.com/blog/articles/2007/12/21/remote-control-of-os-x-tiger-desktop-via-vnc#comment-353</link>
    </item>
  </channel>
</rss>
