How to install Hamachi on Ubuntu 8.04 as a service
This procedre will make hamachi start as a service without any interaction from the user on ubuntu hardy heron 8.04.
Hamachi is a vpn solution that will not require any firewall port forwarding. I use this program to connect to my work computer from home and vice versa. I have been using it for a couple of years and I find that I could not live without it. Through many months of searching and testing I have created an easy way to get hamachi to run as a service in ubuntu. Normally you would have to run /sbin/tuncfg with sudo to get hamachi to run. If you are logged in to a remote location and you rebooted the remote machine, there was no way to log back in until someone ran “sudo /sbin/tuncfg”, and “hamachi start” from the keyboard of the remote machine.
I have been using a script that I found in the ubuntu forums that works perfectly. I have gone a step further and mada another script to automate the process of installation. Below you will find two files that are needed to install hamachi from scratch. The first file is my script, and the second is a text file.
The first thing you will have to do is download both files posted below and save them to your home directory. On line #5 in the text file it reads
USER=username
You have to change 'username' to the user you are logged in as. Ie: drew
You will also have to edit line #9 in the script to reflect the username that you are logged in as.
Next it is time to create a root password if you have not done so already. This is because when you attempt to run the script with sudo you will not have enough privilages to write to the directories that are needed. Using sudo will only give you elevated user privilages and not root privelages. Open a terminal and type
sudo passwd root
supply your user password
Next, switch to the root user. Type
su
or
sudo root
supply your new root password
Now you can run the script by typing
./autostarthamachi
The script will download and install hamachi from sourceforge.net and install it as well as create the files needed to run hamachi as a service.
Once the script is done running, you can type
exit
to return you to your normal user.
Now it is time to setup hamachi. First you will need to run
hamachi-init
This will generate the keys for hamachi
Then you will need to start hamachi
hamachi start
Then run
hamachi login
to put the daemon online and to create an account.
hamachi join <network>
to join the network.
hamachi go-online <network>
to go online in the network.
hamachi list
to list network members and their status.
Once you have hamachi installed and running you can reboot your machine and check that hamachi is running and logged in by typing
hamachi list
If hamachi does not complain then everything was a success.
If you would like to try a very nice gui, I highly recommend 'hamachi-gui'
Good luck and enjoy.
Comments welcome
- Add new comment
- 2004 reads


upx-ucl
Thanks for very useful tool.
Recently I tried your script and found one thing to be fixed in "autostarthamachi".
The command "apt-get install upx-ucl-beta" didn't work because upx-ucl is not a beta version now.
It worked well after "apt-get install upx-ucl."
Hope this helps :).
upx-ucl
Thank you for pointing that out. I will update the script.
Did you try it in hardy or in intrepid?
upx-ucl
Sorry for late reply.
I tried it in intrepid.
upx-ucl-beta
In the repos - Hardy it is still in beta - so leave the script as it is
Intrepid the upx-ucl in not in beta so remove the tail end " -beta"
Later I will post two scripts. One for Hardy and one for Intrepid.
Hamachi does not autostart for me :(
Hi, I followed the instructions above, and i get get Hamachi running in my session, but when I restart. Hamachi does not come up. If I open a terminal, I need to do "sudo tuncfg" then "hamachi start" manually to get hamachi to startup.
Any idea's where I might have gone wrong?
Try looking at the file
Try looking at the file /etc/init.d/hamachi and make sure that the first line reads 'USER=yourusername'
If is reads root then you just have to change it to your user name and everything should work fine.
Cool
If anyone gets the following error: "tap: connect() failed 2 (No such file or directory)"
run 'sudo tuncfg' first, then 'hamachi start' etc.
Also, the 'autostarthamachi' and 'hamachi' scripts will be unable to run unless they are given permission to do so. I just right clicked on both files, went to Properties>Permissions and checked 'Allow executing file as program'.
One more thing... Any idea why I can't start hamachi as a regular user? I have to start, login, list, stop etc. with sudo or it doesn't work right.
Great Tutorial and Scripts, Thank you!
Regular user
I tried running the script as a regular user but it crapped out when it got to the startup scripts.
Regular user? Why?
If you run it as a regular user, it definitely won't work. The first time I did this, (with the information on the ubuntu forums http://ubuntuforums.org/showthread.php?t=135036) I didn't switch to root, I just ran every command with sudo.
I don't know if these scripts require running as root, but at least try running the scripts with sudo.
Just tried it
I just tried running the script with sudo, instead of switching to root. It worked fine. There is absolutely no need to switch to root to run the script!
Start up scripts
When you ran it with sudo did it get past the startup scripts?