question

vassilis-bourdakis avatar image
vassilis-bourdakis asked

remote access to VenusOS: ZeroTier-One installation on RPi [HOW-TO]

hello all,


I managed to compile and install ZeroTier-One remote access service on a Rpi3B+ and a Rpi4 2GB running 2.70 3 Large and 2.70 4 Large16 respectively. It's less than half an hour job and imho well worth doing.

First you get into zerotier.com, setup an account and create a personal network. Pretty straight forward, Found these instructions helpful https://iamkelv.in/blog/2017/06/zerotier.html


Then on a Venus OS terminal window and the root dir (/home/root) do the following.

First grab the file from github (note better have a look with your browser for the latest ver, 1.6.4 was the latest this week):

wget https://github.com/zerotier/ZeroTierOne/archive/1.6.4.tar.gz

takes a few mins (depending on speed) then uncompress and build the folder/subfolders:

tar xf 1.6.4.tar

this builds the whole filestructure, so next get into the dir:

cd ZeroTierOne-1.6.4

and type:

make

this will take approx 15mins with lots of text passing from the screen. Some warnings for unused variables but nothing serious. Following type:

make install

moves produced executables wherever they should be.

Now it's time to setup zerotier-one as a service before rebooting. So, go to /data:

cd /data

and using your favourite editor (I use vi) create a file called rc.local. Contents must be:

#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

/usr/sbin/zerotier-one

exit 0

save and exit. Now last step is to make that file executable:

chmod +x rc.local

followed by a reboot:

reboot -n

On restart, service must be running. Check it with the command (anywhere, /home/root is fine):

zerotier-cli listnetworks

if it starts with 200 it's running fine.

Time to join the network you've created already at the beginning:

zerotier-cli join  #############   (16digits)


that's it! I now have access to the boat via a RUT240 gsm router. Speed is same as when accessing the test rpi next to my desk here at home...


hope it helps someone!


cheers


V.


PS. not a programmer, if you have any suggestions to improve the above, I'm all ears!

Venus OSRaspberry Pi
7 comments
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

mvader (Victron Energy) avatar image mvader (Victron Energy) ♦♦ commented ·

Nice Vassilis! I made one small edit, changed "rpi terminal window" into "Venus OS terminal window".

Some other remarks:

1) running make, and building/compiling zero-tier without first having to install compilers onto your Venus OS install works only on Venus OS Large, as that ships with all tools pre-installed. On other GX devices, one would have to run some opkg commands. Most likely first /opt/victronenergy/swupdate-scripts/resize2fs.sh, to increase file system size, then run opkg update to update the repository, and then run opkg install build-essentials. Don't do this on Venus OS large btw.

2) your zerotier install will be gone if you do an update of Venus OS. A solution would be to install it onto the data partition; but I'm not sure if thats easy to do. Looks like there are quite some files being installed [1]. And the other option I'd try myself is to simply run make install at every boot. A bit crude, but probably works and simplicity has its benefits.

[1] https://github.com/zerotier/ZeroTierOne/blob/master/make-linux.mk#L366

0 Likes 0 ·
vassilis-bourdakis avatar image vassilis-bourdakis commented ·

thanks for all your work Matthijs!

Didn't realise only Large has compiler onboard, another reason to go for the Large version on a 3 and 4 rpi then :-)

Next time I reinstall, I'll see what goes where and try to copy them over only. Actually in /usr/sbin/ there is one file and two symlinks (iirc):

zerotier-one (under 2MB) and

zerotier-cli & zerotier-idtool both symlinks to zerotier-one.

and the startup script in /data.

well for the fun of it, removed the whole ZeroTierOne-1.6.4 folder from my root, rebooted, service is up, everything seems to be running.

So (forgetting man pages which I don't even know where they are) it seems that it only runs with the three files mentioned above plus the startup script. Is that possible?


cheers


V.

0 Likes 0 ·
mvader (Victron Energy) avatar image mvader (Victron Energy) ♦♦ vassilis-bourdakis commented ·

Looking at that install section in the mk file I linked, its also a series of symlinks.


why not install it a every boot?

0 Likes 0 ·
vassilis-bourdakis avatar image vassilis-bourdakis mvader (Victron Energy) ♦♦ commented ·

yes, not a big issue, that's what I'm planning to do, just curious if it would work without. Will have another look on next install.

0 Likes 0 ·
gnagflow avatar image gnagflow mvader (Victron Energy) ♦♦ commented ·

Hi, you said its best to install zerotier at every startup to be sure that any update has no effect to the availability of the remote access service ...

which kind of autostart is save from updates? can i use crontab, a service unit?

thank you!

Update: Found your answer in:

https://www.victronenergy.com/live/ccgx:root_access


Unfortunately, installing this takes about 30min at the Multiplus GX. Thats quite not a good solution. Is there any other workaround. I need to have remote ssh access to my customers to change bms settings if required.

ZeroTier works great. But the installation on the 2.90 large is very long.

0 Likes 0 ·
gnagflow avatar image gnagflow commented ·
Hi, I followed your instructions and Zerotier works realy great. Did you find a solution that an gx updated does not delete the installation. Do you have any hints how to do that?

thank you.


0 Likes 0 ·
vassilis-bourdakis avatar image vassilis-bourdakis gnagflow commented ·
sorry no, but tbh considering that nowadays I'm upgrading Venus a couple of times each season, it's worth getting the latest ZeroTierOne version, so I just update that as well as part of the new install like I did this week that I moved to 2.91.


V.

0 Likes 0 ·
4 Answers
Kevin Windrem avatar image
Kevin Windrem answered ·

To automate reinstalls and not repeat work that has already been done (and slows the boot-up process) you need to check to see if the file system has been updated. I developed a mechanism to automate reinstalls after a Venus OS update.

https://github.com/kwindrem/SetupHelper

It hooks into your install scripts to automate certain tasks, but it also tests for the existence of a "i'm already installed" flag file in a part of the file system that is overwritten by the software update. So if the installed flag is present, the script can skip the install.

The other thing worth considering is to set up a "service" that will run zeroteir. This is more or less equivalent to putting a call to zeroteir in rc.local but has the advantage that you have control over the application, and if it quits will be automagically restarted. Most Venus OS functionality is managed as a service so there are lots of examples. Look in /service.

2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

vassilis-bourdakis avatar image
vassilis-bourdakis answered ·

thanks Kevin,

already using your SetupHelper for new installations, will look into it.

Mind if firmware update becomes functional in rpi installs as well, I guess it's going to be only a task when starting afresh with an install.
Re rc.local, had enough trouble making this work, haven't actually done anything in *nix for decades... Will check service, currently stuck in getting rpi sh (which seems like it's bash) to read .bash_profile on a new ssh session from my windows machine (putty) so that I don't have to realias all the ls -la and ls -la|more I'm typing now...

cheers

V.

1 comment
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

5teve avatar image 5teve commented ·
Being a bit of a dummy - is there any further guide to doing this on a non large installation and using @Kevin Windrem Setup helper (already using his GUImods)? I'm wanting SSH access over 4g LTE and apart from getting a decent router and separate LTE modem.. this could be my way in.. :)


Steve

0 Likes 0 ·
mapeje avatar image
mapeje answered ·

Another way is to install zero Tier in the router. I run on a RUT240 with great success. Also direct access to my Shellies.

2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

sungunner avatar image
sungunner answered ·

Is there an update to this? I looked for the archive folder and it no longer exists...

https://github.com/zerotier/ZeroTierOne/archive/1.6.4.tar.gz

2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.