How to set up a Commercium Masternode in Linux

Post Jok
Commercium Guides
Published in
8 min readFeb 16, 2019

This tutorial will guide you through the process of setting up a masternode for Commercium in a few simple and easy steps.

A masternode is simply a full node that keeps a full copy of the blockchain stored on it, and is always up & running. Masternodes help the blockchain achieve more stability, accelerate network synchronization, and the more masternodes get added overtime, the stronger it becomes. Commercium blockchain technologies is also planning on using masternodes to prevent 51% attacks through their Block Inquiry System.
As compensation, a user that has deployed and maintains a masternode, gets a portion of the block reward.

1) Setup your VPS

A Virtual Private Server, VPS or often called a cloud server, runs a fully functional installation of an operating system (usually Linux) on a virtual machine, accessible over the Internet.

The virtual machine allows the VPS provider to run multiple systems on one physical server, making it more efficient and much cheaper than having a single operating system running on the “bare metal “ of each server.

A VPS is ideal for hosting a Commercium masternode because they typically offer guaranteed up-time, redundancy in case of hardware failure, and a static public IP address, all of which is required to ensure you remain online, and in the masternode payment queue. While running a masternode from home on a desktop computer is technically possible, it will most likely not work reliably because most ISPs allocate dynamic IP addresses to home users.

We will use a Vultr ‘Instance’ for this example, although , Amazon EC2, Google Cloud, Choopa and OVH are also popular choices. First create an account and add credit. Then go to the Servers menu item on the left and click + to add a new server. Select a location for your new server on the following screen:

Select a location for your new server
Select Ubuntu 16.04 x64 or 18.04 x64 as the server type.
Select a server size offering at least 1GB of memory, 1 CPU and 25 GB SSD.

Enter a hostname and label for your server.

Vultr will now install your server. This process may take a few minutes.

Click Manage when installation is complete and take note of the IP address, username, and password.

The VPS setup example is specific for Vultr and will vary slightly depending on what VPS service you may choose.

2) System setup

We will begin by connecting to your newly provisioned server. On Linux, we can ssh directly from the terminal - simple type ssh root@<server_ip> and enter your password when prompted or download Putty for Linux via the terminal

sudo apt update
sudo apt install putty

Enter the IP address of the server into the “Host Name” field. Standard default port for SSH is 22.

Click Open.

You may see a certificate warning pop-up window since this is the first time you are connecting to this server. You can safely click ‘Yes’ to trust this server in the future.

You are now connected to your server and should see a terminal window. Begin by logging in to your server with the user root and password supplied by your hosting provider.

The first thing you should do is run the following command to update the current linux distribution to the latest updated version:

sudo apt-get update && yes | sudo apt-get upgrade && yes | sudo apt-get dist-upgrade
reboot

3) Security settings

The default security settings on Linux are pretty decent and better than most of its competitors, but it still has weaknesses.

A little time and effort spent when first setting up your VPS can go a long way to protecting it, and will ensure that you don´t have to worry about your masternode being secure.

3a.) Change password

You should immediately change the root password and store it in a safe place with the following command, logged in as root:

passwd

You can copy and paste any of the following commands by selecting them in your browser, pressing Ctrl + C, then switching to the PuTTY window and right-clicking in the window. The text will paste at the current cursor location. (Note: the Ctrl + V keys to ‘paste’ as used in Windows, will not work in Linux). Enter and confirm a new password, preferably long and randomly generated.

3b.) Change SSH port

The default port assigned to SSH is 22 and your VPS will sit and listen on this port for incoming connections.

Unfortunately, malicious users (‘hackers’, ‘script kiddies’, etc.) know this and there does exist a certain degree of ‘background noise’ of automated attack malware on the Internet that will scan random IP addresses to see if port 22 is open, and if it is, attempt a barrage of automated SSH logins using common, weak, guessable passwords.

To change the port SSH is running on, SSH into your VPS as the ‘root’ user. Type:

nano /etc/ssh/sshd_config

You should see the configuration file opened inside nano:

About the fifth line down it should read Port 22

We are going to change this to something else. Any port will do the trick, as long as it is not a “well known” port. You can check this list for guidance.

For this example, lets choose 3256. Move with the arrow keys to the specific location, delete 22 and replace it with 3256, so that the line now reads as:

Port 3256

Then, hit Crtl-o to save the file, then press Enter, and lastly Crtl-x to exit the nano editor.

You will have to restart the server for the change to take affect, but we will do it later after we finished the configuring security settings.

3c.) Enable firewall

Its purpose is to control what traffic is allowed to traverse from one side to the other. Firewalls can block traffic intended for particular IP addresses and/or server ports.
Type in the following commands one at a time.

apt-get install ufw 
ufw allow ssh/tcp
ufw limit ssh/tcp
ufw allow 2019 (port of the P2P network of Commercium)
ufw allow 3256 (port which we are connecting to via SSH)
ufw logging on
ufw enable

Now, restart the SSH server connection to make the changes take affect.

service ssh restart

Don’t log out of the current SSH session, just open a new putty session. If we have a typo or some other error, you can undo the changes and won’t be blocked out of your server.

You will have to change the port to 3256 in PuTTY, as port 22 is now blocked.

If PuTTY can connect to the new port and you can login with your new password and we did everything right!

4) Core Wallet

Type the following commands one by one into the terminal

sudo apt-get update && sudo apt-get install libgomp1cd && mkdir commercium && cd commerciumwget https://github.com/CommerciumBlockchain/CommerciumContinuum/releases/download/v1.0.5/commercium_continuum-v1.0.5-linux.tar.gztar zxvf commercium_continuum-v1.0.5-linux.tar.gzcp commercium_continuum-v1.0.5-linux/* ../fetch-params.shcdmkdir .commerciumnano .commercium/commercium.conf

Paste the following lines into the file, then ctrl + x → Yes → Enter to save and exit.

txindex=1
daemon=1
server=1
listen=1
rpcuser=youruser
rpcpassword=yourpassword
rpcport=12019
addnode=seed01.commercium.net
addnode=seed02.commercium.net
addnode=seed03.commercium.net
addnode=seed04.commercium.net

To start the client

./commercium/commerciumd

5) Local configuration

Let the wallet synchronize to 100%

Open another terminal and type the following commands into the second window

cd commercium

./commercium-cli getnewaddress

Take note of the collateral address, since we will need it later, and export the private key for additional security. Now send exactly 100000 CMM in a single transaction to the address you generated in the previous step. This may be sent from another wallet or from funds already held in your current wallet.

Now let´s get the masternode private key and outputs

./commercium-cli masternode genkey
./commercium-cli masternode outputs

Write both values down

nano ~/.commercium/masternode.conf

Configure as following from left to right

Alias name: e.g. MN1
VPS IP: IP address of VPS
Priv key: Masternode private key from the obove step
Outputs: Masternode outputs from the above step

Ctrl + x → Yes → Enter to save and exit

./commerciumd stop
./commerciumd

5) VPS setup

Open PuTTY or the console again and connect to VPS via SSH using the username and new password you created earlier.

5a.) Installation:

Copy the following command into the VPS command line

curl -O https://raw.githubusercontent.com/CommerciumBlockchain/masternode-scripts/master/part2_linux_vps_setup.sh > part2_linux_vps_setup.sh
bash part2_linux_vps_setup.sh

As this is an automated script, just follow along and answer the questions as prompted in the console (you will need your masternode private key)

At the end of the installation, the daemon will start and begin syncing to the blockchain automatically.

5b.) Starting the masternode:

Local terminal

./commercium-cli startmasternode all missing

If we did everything the right way, the output should say Success

VPS terminal

To see if the masternode successfully started, type

cd commercium_continuum-v1.0.5-linux
./commercium-cli masternode status
./commercium-cli masternodedebug

Congratulations — you now have a operational masternode!

You can reach us via the links below, if you have further questions about the masternode setup process or Commercium Blockchain Technologies in general.

Website: https://www.commercium.net/

Discord: https://discord.gg/st9pCjk

Telegram: https://t.me/CommerciumOfficial/

Twitter: https://twitter.com/CMMBlockchain

--

--

Post Jok
Commercium Guides

Community Manager and Marketing Consultant at Commercium Blockchain Technologies