How to get Turris Omnia 2G serial number from command line

I have a turris omnia 2G working as a kind of Gateway to an Azure IOT-Hub. I am using the routers serial number in order to identify each router individually in the Azure cloud. Using MAC address is not an option. This serial number is manually entered as a commandline argument to an Azure application running on the router. I am looking for a way to retrieve the routers serial number by using a command. Is there such a command available? running cat /proc/cpuinfo returns all zeros for Serial.
Thanks in advance…

There is a cryptochip in Omnia which puts out a serial number.

atsha204cmd serial-number

Edit: see this post for a better solution


Thank you.
It appears that this command is working fine and outputting the hexadecimal representation of the serial number. Many thanks! Would it be possible to call this somehow from a LXC container?

You have to have access to i2c device (i don’t rember which one, strace is your friend). Access to this device has to be allowed by container and you have to build atsha utility. You can found sources on our gitlab.

Thanks. I will give it a try.

Above mentioned command display SN in hex, while Foris “About” display it in digital. I’ve created simple scipt (maybe brute force, not much elegant) to display it in digital, as well :wink:

- root@turris:~# cat -
# print Turris Omnia serial number (translated from hex to digital)
# atsha204cmd serial-number > SNs
/usr/bin/crypto-wrapper serial-number > SNs
echo -n "serial-number: " `cat SNs` " "
 hexdump -e '16/1 "%02x ""\n"' SNs | \
  tr ' ' '\n' | \
   head -16 > SNh
awk -f SNa SNh
rm SNh SNs
- root@turris:~# cat SNa -
BEGIN { leading = 0
        exponent = 17
        value[1] = 1; digit[30] = 0
        value[2] = value[1] * 16; digit[31] = 1
        value[3] = value[2] * 16; digit[32] = 2
        value[4] = value[3] * 16; digit[33] = 3
        value[5] = value[4] * 16; digit[34] = 4
        value[6] = value[5] * 16; digit[35] = 5
        value[7] = value[6] * 16; digit[36] = 6
        value[8] = value[7] * 16; digit[37] = 7
        value[9] = value[8] * 16; digit[38] = 8
        value[10] = value[9] * 16; digit[39] = 9
        value[11] = value[10] * 16; digit[41] = 10
        value[12] = value[11] * 16; digit[42] = 11
        value[13] = value[12] * 16; digit[43] = 12
        value[14] = value[13] * 16; digit[44] = 13
        value[15] = value[14] * 16; digit[45] = 14
        value[16] = value[15] * 16; digit[46] = 15
        serial = 0
        total = 0
   if ( leading == 0 )
     if ( $1 == 30 )
        leading = 1
        serial = value[exponent]*digit[$1]
        total = serial+total
   serial =+ value[exponent]*digit[$1]
   total = serial+total
END { print total }

BTW, it is part of another script, displaying some information about TO router in SSH session… which is called in “.profile”

- root@turris:~# cat .profile -
- root@turris:~# cat -
# display some basic information
echo -n "uptime: "
cd /etc
for i in openwrt_version turris-version
   do echo -n "$i: "
      cat $i
echo -n "branch: "
/usr/bin/switch-branch --verify 2>&1 | grep VBRANCH | grep -v =- | sed 's/+ VBRANCH=//'
echo -n "thermometer: "
cd /root
cd /etc
lxc-info -n KontUb
lxc-info -n KontDeb
echo pro aut. start kont. po bootu: vi /etc/config/lxc-auto

You should rather use crypto-wrapper serial-number instead of atsha204cmd utility. The most advantage of it is that it is not using the crypto chip and it should be faster and it can be used for all our routers including Turris MOX.


Thanks for hint. Script updated.

With bash, you can simply do:

echo $(( 16#$(crypto-wrapper serial-number) ))

Elegant! Unfortunately not working:

root@turris:~# echo $(( 16#$(crypto-wrapper serial-number) ))
-ash: arithmetic syntax error

Most probably due difference between bash and ash in BusyBox :frowning:

Exactly my problem :wink:
I use this in my /etc/rc.local:
printf "%d" 0x$(crypto-wrapper serial-number)
It works both in ash and bash.


Beware of quotation marks in Discuss. If the command is not marked as program source the quotation marks will be converted and copy&paste will not work.

This should work:

printf "%d" 0x$(crypto-wrapper serial-number)


One lives to learn…
Thanks a lot. I edited my post.

Thanks to all giving hints.

This is why I specified bash (which I am using as my default shell as it is way better than ash).

Good idea to use printf.

Didn’t know there is bash in TOS :frowning:

But, even though using your suggesion (with or without paths for bash and crypto-wrapper, I got error “/bin/echo: /bin/echo: cannot execute binary file”.

EDIT: above error was on SSH session on Samsung tablet 10.1 :wink: with prehistoric Android version :wink:

On SSH session on current Win 10 PC I got another error:

root@turris:~# echo $(( 16#$(crypto-wrapper serial-number) ))
-ash: arithmetic syntax error
root@turris:~# /bin/bash echo $(( 16#$(/usr/bin/crypto-wrapper serial-number) ))
-ash: arithmetic syntax error

If you want to use bash, either, just type /bin/bash and you will be in a bash shell or use bash -c “your command” to run only one command with bash. In that specific case, you’ll want to use single quote to prevent ash from interpreting the $…

bash -c 'echo $(( 16#$(crypto-wrapper serial-number) ))'

Nice, it really works :wink: As @iany wrote above, one have to learn again and again.