Monday, September 7, 2009

Installing Hamachi for remote desktop (VNC) over VPN

Install Hamachi on Ubuntu 9.04

1. To being we must turn on the ‘tun’ module to enable IP Tunneling support for the Linux kernel. Most do not have this setup by default.

$ sudo modprobe tun

2. Open the modules file and add ‘tun’ to the list

$ sudo vi /etc/modules

3. Your file should look similar to the example below.

# /etc/modules: kernel modules to load at boot time.
#
# This file contains the names of kernel modules that should be loaded
# at boot time, one per line. Lines beginning with "#" are ignored.

lp
rtc
tun

4. Save the file and exit out of vi, lets move on and verify that a tunneling node has been created. (*If you have compiled your own kernel you likely need to recompile it with IP Tunneling support if you receive an error with modprobe. This is not covered in this guide. And if you are unsure, you most likely did not compile yourself and you would definitely remember doing so.)

$ ls /dev/net/tun

5. You should recieve a response like the example below

/dev/net/tun

6. If you received something along the lines of “No Such File or Directory” you may need to manually create the node in step 6. If you received the same response as I did, jump to step 7.

$ sudo tuncfg

Jump back to Step 4 and you should now receive the correct response.
7. With our IP Tunnel node created, it is time to install Hamachi itself. First download the latest version. As of writing this guide, the latest version is 0.9.9.9-20

$ wget http://files.hamachi.cc/linux/hamachi-0.9.9.9-20-lnx.tar.gz

Expected output below

--2009-07-31 20:28:25-- http://files.hamachi.cc/linux/hamachi-0.9.9.9-20-lnx.tar.gz
Resolving files.hamachi.cc... 69.25.20.50
Connecting to files.hamachi.cc|69.25.20.50|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 344866 (337K) [text/plain]
Saving to: `hamachi-0.9.9.9-20-lnx.tar.gz'

100%[====================================================================>] 344,866 448K/s in 0.8s

2009-07-31 20:28:26 (448 KB/s) - `hamachi-0.9.9.9-20-lnx.tar.gz' saved [344866/344866]

8. Extract our newly downloaded archive

$ tar zxvf hamachi-0.9.9.9-20-lnx.tar.gz

Expected output below

hamachi-0.9.9.9-20-lnx/
hamachi-0.9.9.9-20-lnx/Makefile
hamachi-0.9.9.9-20-lnx/LICENSE
hamachi-0.9.9.9-20-lnx/README
hamachi-0.9.9.9-20-lnx/LICENSE.tuncfg
hamachi-0.9.9.9-20-lnx/LICENSE.openssh
hamachi-0.9.9.9-20-lnx/LICENSE.openssl
hamachi-0.9.9.9-20-lnx/hamachi
hamachi-0.9.9.9-20-lnx/tuncfg/
hamachi-0.9.9.9-20-lnx/tuncfg/Makefile
hamachi-0.9.9.9-20-lnx/tuncfg/tuncfg.c
hamachi-0.9.9.9-20-lnx/tuncfg/tuncfg
hamachi-0.9.9.9-20-lnx/CHANGES

9. Navigate into the extracted directory

$ cd hamachi-0.9.9.9-20-lnx/

10. Start the installation

$ sudo make install

Expected output below

Copying hamachi into /usr/bin ..
Creating hamachi-init symlink ..
Compiling tuncfg ..
Copying tuncfg into /sbin ..

Hamachi is installed. See README for what to do next.

11. Run the tunnel

$ sudo tuncfg

12. This should complete the install, we will now configure the user permission in order for it to run correctly. Create a ‘hamachi’ user group

$ sudo groupadd hamachi

13. Add youself as a user to the ‘hamachi’ group. Be sure to replace your user name where appropriate.

$ sudo gpasswd -a YOURUSERNAME hamachi

14. Add the root user to the ‘hamachi’ group

$ sudo gpasswd -a root hamachi

15. Set the correct permissions for the tuncfg socket

$ sudo chmod 777 /var/run/tuncfg.sock

16. Change the ownership of the socket file

$ sudo chgrp hamachi /var/run/tuncfg.sock

17. That should do it for the permissions, Now onto setting Hamachi up & configuring it to start as a system service.

$ hamachi-init

Expected output

Initializing Hamachi configuration (/home/jasonong). Please wait ..

generating 2048-bit RSA keypair .. ok
making /home/jasonong directory .. ok
saving /home/jasonong/client.pub .. ok
saving /home/jasonong/client.pri .. ok
saving /home/jasonong/state .. ok

Authentication information has been created. Hamachi can now be started with
'hamachi start' command and then brought online with 'hamachi login'.

18. Start hamachi

$ hamachi start

Expected output

Starting Hamachi hamachi-lnx-0.9.9.9-20 .. ok

19. Set your computer’s nickname

$ hamachi set-nick "COMPUTERNICKNAME"

20. Login to the Hamachi network

$ hamachi login

21. To join an existing network (optional) “NETWORKNAME” and “PASSKEY” should be replaced with your network name and network password

$ hamachi join NETWORKNAME PASSKEY

22. To create a new network (optional) “NETWORKNAME” and “PASSKEY” should be replaced with your network name and network password

$ hamachi create NETWORKNAME PASSKEY

23. If you joined an existing network you must tell hamachi to then “go-online”. Be sure to replace NETWORKNAME with your relevant network name.

$ hamachi go-online NETWORKNAME

24. Check your hamachi status to verify everything is as it should be

$ hamachi

Expected outputhamachi -c /etc/hamachi start


Hamachi, a zero-config virtual private networking utility, ver 0.9.9.9-20

version : hamachi-lnx-0.9.9.9-20
pid : 5472
status : logged in
nickname : JasonOng

Known Issues

And that pretty much completes the install. Just some words of advice from some small issues that I’ve run into. I’ve found it best to create a network with a Windows computer. The windows client supports network messaging, where the OS X and Linux clients do not. This is important because if you later choose to move control to https://my.hamachi.cc , only the windows client will be able to receive the network message and reply to it. Allowing administrative controls to be transfered and managed from the website. OS X and Linux clients cannot do this at this point in time.

Install gHamachi GUI

First, visit the Hamachi forums and download the most recent version of the gHamachi frontend for either gtk 2.0 or gtk 1.2 (whichever you prefer).

gHamachi can be found here.

Second, simply unpack the gHamachi tarball, copy the binary to /usr/bin, and give it permission to run (chmod +x).

Code:

tar xfz gHamachi_gtk2.tar.gz
sudo mv ghamachi /usr/bin/
sudo chmod +x /usr/bin/ghamachi

Once that is done, the Hamachi GUI is completely installed.

Start the GUI like this:
Code:

ghamachi

No comments:

Blog Archive