commandline-starter-guide-for-immudb


Using immudb codeless

immudb provides insanely fast tamperproof storage that can keep up with high-performance databases. If you have a requirement for immutability, immudb is the right tool for you. Immudb can be used to secure logs of transaction systems and databases or many more things like securing CI/CD pipelines. Only your imagination is the limit. There is just one little caveat. Even if you have the greatest imagination, most tools require advanced coding skills stopping you from implementing your visions. That’s why our hardworking gophers did their best to make immudb easy to use. Infact you can try out immudb without writing a single line of code by using our immuclient.

Install and run immudb

Installing immudb is easy. Immudb is written in go, that’s why you will have to install golang. Download the release binaries of immudb and immuclient for Linux, Mac OS (darwin) or Windows. Run immudb as follows:

# run immudb in the foreground
./immudb

# run immudb in the background
./immudb -d

You may want to restart immudb, in that the running instance must be stopped first. To stop immudb you need to find the process ‘ps -ax | grep immudb’ and then ‘kill -15 ‘. Windows PowerShell would be ‘Get-Process immudb* | Stop-Process’.

Start immuclient from your immuclient directory with ./immuclient –help to look at the options.

Using immudb with immuclient

Let’s get started using immudb with the immuclient. In this blog, we will create an example bash script that will create a folder with multiple files. Then we will get the checksums of those files and save them together with the file name in immudb. Doing so we need an authorized connection to immudb. The default user is "immudb" with the default password of "immudb". The immuclient will ask you for the password and will remind you of changing the password because using default passwords is not safe. It is okay for playing around though!

#!/bin/bash

# Replace with our immudb path
export PATH="/home/sebastian/immudb2/immudb:$PATH"

# Delete sample data if it exists
if [ -d "$(pwd)/data/" ]; then
    rm -r data
fi

# Create directory and files
mkdir data
cd data
echo 'This content will be hashed by blake 2 and stored in immudb.' > file1.txt 
echo 'This information is important and no one should be able to tamper it unseen.' > file2.txt 
echo 'These files could contain anything. For example log data or sensitive customer data.' > file3.txt 
echo Files created!
# Immudb login
immuclient login immudb 
#immuclient use <yourdatabase>

Output:

Files created!
Password:
Successfully logged in.
immudb user has the default password: please change it to ensure proper security

Immudb is designed as a key-value database. Saving key values with immuclient is quite easy. Note that "safeset" will not only safe the key-value combination, it will also verify the write-operation. The script will iterate over every file in the directory and create a checksum with the BLAKE-2 algorithm. The output will then be stored in immudb.

# Iterate over all files and get BLAKE-2-hash
# Save Hash as key with filename as value in immudb
for file in *; do
    if [ -f "$file" ]; then 
        #echo "$file"
        #b2sum algoritm SHA-3
        b2s=($(b2sum "$file"))
        #save filename b2s[1] and checksum b2s[0] as key-value pair in immudb
        immuclient safeset ${b2s[1]} ${b2s[0]}
    fi
done

Output of safeset:

tx:     1 
key:        file1.txt 
value:      b74fb96658cc1526c8855b2c26352586398a46f3dc22d98940fb200af51b30e5136a7a6b8e00e4d862a825a4377ca7df25f809c882e69db7a5075848f5e05f87 
hash:       f2c420c87111cc0eb0525a96bbdfa84e087bd955dbb3910d16aba4b5f9862d42 
verified:   true 

tx:     2 
key:        file2.txt 
value:      d84c0a271d4b847ddd14af3fec750b5f2f40c3a67b015be37efbb6c819fedb00ede8936ba604d72777219f0a5987a1ed7002105e8cbd181fadd5b4813efd208c 
hash:       92151b189354cf326f9ba21c7a842d2d2b92e59a6c17e900f9705a277f49952e 
verified:   true 

tx:     3 
key:        file3.txt 
value:      8ea716717c3b11bbc421776dca36641912cd49fa356de2e72da2a1f2cafb0f9748111c6d098282f54c935e354920806309ac9c75d1bf47e5e62cb14d53a23b45 
hash:       56be327a1bc1552d2c6549d2c3d3d38e2c8b58e4d482fec2adba6e56aa6841a9 
verified:   true 

The information about the files is now stored immutable and verifiable in immudb. Now we do the other way around and look up the data of the files. Therefore we use the filename and do a verified read with immuclient safeget. Again the script is iterating over all files in the directory and requesting the values. It compares them to the actual checksum and reports if they match with the value from immudb.

# Iterate over files and safeget values
# Compare value to realtime checksum and report matches
for file in *; do 
    output=$(immuclient safeget "$file")
    value=$(echo "$output" | grep "value" | awk '{print $NF}')
    b2out=($(b2sum "$file"))
    echo $b2out
    echo $value
    if [ "$b2out" == "$value" ]; then
        echo match for "$file"
    fi
done

Output comparison loop:

b74fb96658cc1526c8855b2c26352586398a46f3dc22d98940fb200af51b30e5136a7a6b8e00e4d862a825a4377ca7df25f809c882e69db7a5075848f5e05f87
b74fb96658cc1526c8855b2c26352586398a46f3dc22d98940fb200af51b30e5136a7a6b8e00e4d862a825a4377ca7df25f809c882e69db7a5075848f5e05f87
match for file1.txt
d84c0a271d4b847ddd14af3fec750b5f2f40c3a67b015be37efbb6c819fedb00ede8936ba604d72777219f0a5987a1ed7002105e8cbd181fadd5b4813efd208c
d84c0a271d4b847ddd14af3fec750b5f2f40c3a67b015be37efbb6c819fedb00ede8936ba604d72777219f0a5987a1ed7002105e8cbd181fadd5b4813efd208c
match for file2.txt
8ea716717c3b11bbc421776dca36641912cd49fa356de2e72da2a1f2cafb0f9748111c6d098282f54c935e354920806309ac9c75d1bf47e5e62cb14d53a23b45
8ea716717c3b11bbc421776dca36641912cd49fa356de2e72da2a1f2cafb0f9748111c6d098282f54c935e354920806309ac9c75d1bf47e5e62cb14d53a23b45
match for file3.txt

With immudb a whole lot of things can be used as "values" for example hash values of repositories, files, and even docker containers. Saving a key twice is possible. Each key will be handled in its own table and only show the most recent value by querying with "get" or "safeget". That’s why there is a history function that will show us the history of a certain key.

echo $(immuclient history file1.txt)

Output of the histoy of file1.txt:

tx: 1 key: file1.txt value: b74fb96658cc1526c8855b2c26352586398a46f3dc22d98940fb200af51b30e5136a7a6b8e00e4d862a825a4377ca7df25f809c882e69db7a5075848f5e05f87 hash: f2c420c87111cc0eb0525a96bbdfa84e087bd955dbb3910d16aba4b5f9862d42

Starting immudb with docker in 3 minutes (optional)

Install Docker and pull the immudb as image from Docker Hub in seconds.

immudb has already been downloaded over 1 million times. Pull immudb and immuclient for this tutorial:

#take care of matching versions
docker pull codenotary/immudb:latest
docker pull codenotary/immuclient:v0.9.0-RC1

Now start the immudb and immuclient. We also create a network so immuclient can communicate with our immudb container.

docker network create immudbnet
docker run -d --net immudbnet -it --rm --name immudb -p 3322:3322 codenotary/immudb:latest
docker run -it --rm --net immudbnet --name immuclient codenotary/immuclient:latest -a immudb

If everything worked out, you are now in the shell of immuclient. Type "– help" to look up the options.

Manage immudb with immuadmin (optional)

immuadmin is a powerful tool to manage your immudb installation. You can install and manage the service installation for both components and get statistics as well as runtime information.
When logging in for the first time you will have to change your default password. It must contain upper and lower case letters, digits, punctuation mark or symbol.

immuadmin can be downloaded as release binary or used as a docker container just like immudb and immuclient.

#default user immudb, default password immudb
./immuadmin login immudb

After logging in successfully immuadmin allows creating new databases.

./immuadmin database create testdb
database successfully created
./immuadmin database list
2 database(s)
-  -------------  
#  Database Name  
-  -------------  
1  defaultdb      
2  testdb         
-  -------------  

Clients can now switch to the newly created database. One of the most requested activities for every admin is resetting or changing passwords. This can be done through immuadmin user commands. For example:

./immuadmin user changepassword user1

Immutability without a headache

In this blog, we have shown that using immudb is no hassle. In fact you can try it out and test its functionalities without having to code.
Get new ideas and imagine how to make your data immutable.
immudb can scale with your applications providing immutability and adding trust to businesses.

Check out our more detailed post about immudb to dive deeper.

immudb is an open-source technology. Leave a star on our github if you like that.

immudb

BUILT ON THE FASTEST
IMMUTABLE LEDGER
TECHNOLOGY

Open Source and easy to use in new applications and easy to integrate into existing application.

Subscribe to Our Newsletter

Get the latest product updates, company news, and special offers delivered right to your inbox.

Subscribe to our newsletter

Use Case - Tamper-resistant Clinical Trials

Goal:

Blockchain PoCs were unsuccessful due to complexity and lack of developers.

Still the goal of data immutability as well as client verification is a crucial. Furthermore, the system needs to be easy to use and operate (allowing backup, maintenance windows aso.).

Implementation:

immudb is running in different datacenters across the globe. All clinical trial information is stored in immudb either as transactions or the pdf documents as a whole.

Having that single source of truth with versioned, timestamped, and cryptographically verifiable records, enables a whole new way of transparency and trust.

Use Case - Finance

Goal:

Store the source data, the decision and the rule base for financial support from governments timestamped, verifiable.

A very important functionality is the ability to compare the historic decision (based on the past rulebase) with the rulebase at a different date. Fully cryptographic verifiable Time Travel queries are required to be able to achieve that comparison.

Implementation:

While the source data, rulebase and the documented decision are stored in verifiable Blobs in immudb, the transaction is stored using the relational layer of immudb.

That allows the use of immudb’s time travel capabilities to retrieve verified historic data and recalculate with the most recent rulebase.

Use Case - eCommerce and NFT marketplace

Goal:

No matter if it’s an eCommerce platform or NFT marketplace, the goals are similar:

  • High amount of transactions (potentially millions a second)
  • Ability to read and write multiple records within one transaction
  • prevent overwrite or updates on transactions
  • comply with regulations (PCI, GDPR, …)


Implementation:

immudb is typically scaled out using Hyperscaler (i. e. AWS, Google Cloud, Microsoft Azure) distributed across the Globe. Auditors are also distributed to track the verification proof over time. Additionally, the shop or marketplace applications store immudb cryptographic state information. That high level of integrity and tamper-evidence while maintaining a very high transaction speed is key for companies to chose immudb.

Use Case - IoT Sensor Data

Goal:

IoT sensor data received by devices collecting environment data needs to be stored locally in a cryptographically verifiable manner until the data is transferred to a central datacenter. The data integrity needs to be verifiable at any given point in time and while in transit.

Implementation:

immudb runs embedded on the IoT device itself and is consistently audited by external probes. The data transfer to audit is minimal and works even with minimum bandwidth and unreliable connections.

Whenever the IoT devices are connected to a high bandwidth, the data transfer happens to a data center (large immudb deployment) and the source and destination date integrity is fully verified.

Use Case - DevOps Evidence

Goal:

CI/CD and application build logs need to be stored auditable and tamper-evident.
A very high Performance is required as the system should not slow down any build process.
Scalability is key as billions of artifacts are expected within the next years.
Next to a possibility of integrity validation, data needs to be retrievable by pipeline job id or digital asset checksum.

Implementation:

As part of the CI/CD audit functionality, data is stored within immudb using the Key/Value functionality. Key is either the CI/CD job id (i. e. Jenkins or GitLab) or the checksum of the resulting build or container image.

White Paper — Registration

We will also send you the research paper
via email.

CodeNotary — Webinar

White Paper — Registration

Please let us know where we can send the whitepaper on CodeNotary Trusted Software Supply Chain. 

Become a partner

Start Your Trial

Please enter contact information to receive an email with the virtual appliance download instructions.

Start Free Trial

Please enter contact information to receive an email with the free trial details.