Morpheus Cloud Docs

Lemon Validator Set Up

35min

Set up SSH Key

You will need a SSH key to properly secure you VM which hosts the validator (and for the instructions to properly work. The easiest way to generate a public and private SSH key is through a terminal. If you are using a Mac or Linux machine, a terminal is built right in. If you are using Windows, you will need to install a terminal or jump through hoops using Putty to generate a SSH private and public key pair.

Windows WSL To get a terminal on Windows, you need to install WSL. Please do a google search for setting up WSL or troubleshooting the installation. The basics are as follows: Type CMD in the search bar, right-click the CMD app that shows up in the search, select “Run as Administrator”

At the command prompt, type the following:

wsl --install

If everything is ready on your machine, it will install and ask you to reboot. If there are problems, it will ask you to turn on some windows services, or maybe turn on virtualization in your bios. Google is your friend.

Generate an SSH key pair

Using Terminal (mac)

Below document describes how to generate SSH key pairs using the Linux terminal - this is a common task for secure remote access and authentication.

Open your terminal and use the ssh-keygen command:

ssh-keygen -t rsa -b 4096 -C "[email protected]"

Where: -t rsa specifies the type of key (RSA) -b 4096 sets the key length to 4096 bits for strong security -C adds a comment (usually your email) to help identify the key

You'll may be prompted to choose a location to save the key pair (otherwise it will create it in the folder you are currently in; if you change the name, pay attention to what you name it):

Enter file in which to save the key (/home/username/.ssh/id_rsa):

Press Enter to accept the default location, or specify a custom path.

Next, you'll be asked to enter a passphrase (DON’T use a passphrase):

Enter passphrase (empty for no passphrase): Enter same passphrase again:

While optional, a passphrase adds an extra layer of security.

The system will generate your key pair and show a confirmation like:

Your identification has been saved in /home/username/.ssh/id_rsa Your public key has been saved in /home/username/.ssh/id_rsa.pub

View your public key with (this displays the key in text in the terminal; you can copy it to paste it into a text editor, or most importantly, into the SSH key upload field when creating your Validator VM):

cat ~/.ssh/id_rsa.pub

You'll now have two files:

id_rsa: Your private key (keep this secure and never share it) id_rsa.pub: Your public key (this can be shared with services like GitHub or servers)

PuTTY on Windows

To create and use SSH keys on Windows, you need to download and install both PuTTY, the utility used to connect to remote servers through SSH, and PuTTYgen, a utility used to create SSH keys.

On the PuTTY website, download the .msi file in the Package files section at the top of the page, under MSI (‘Windows Installer’). Next, install it on your local computer by double clicking it and using the installation wizard.

After the programs are installed, start the PuTTYgen program through your Start Menu or by tapping the Windows key and typing puttygen. The key generation program looks similar to this:

Document image


You can customize the Parameters at the bottom if you like, but the default values are appropriate in most situations.

When you’re ready, click the Generate button on the right-hand side.

You might be prompted to “generate some randomness by moving the mouse over the blank area”. This randomness, known as entropy, is used to create keys in a secure fashion so that other people can’t reproduce them.

Document image


When the key is generated, you see the public key displayed in a text box. Copy this into your clipboard now if you plan to add it to your DigitalOcean account or to servers. Scroll carefully within the text area so you copy the entire key.

Next, you are prompted to enter a passphrase for your SSH key. This improves security by preventing someone who gains access to your private key from using it without also knowing the passphrase. You need to provide your passphrase every time you use this key (unless you use SSH agent software that stores the decrypted key).

Document image


When you’re done, click the Save private key button and select a secure location to keep it. You can name your key whatever you’d like, and the extension .ppk is automatically added.

If you have not entered a passphrase, you need to confirm that you want to save the key without one. We strongly recommend using a passphrase, but you can press ENTER to bypass this prompt.

Optional: Convert to OpenSSH format

  • Click "Conversions" in the menu
  • Select "Export OpenSSH key" for compatibility with Linux systems

Working with PuTTY’s Public Key Format

You can click Save public key as well, but take note: The format PuTTYGen uses when it saves the public key is incompatible with the OpenSSH authorized_keys files used for SSH key authentication on Linux servers.

If you need to see the public key in the right format after the private key has been saved:

  1. Open PuTTYgen.
  2. Next to Load an existing private key file, click the Load button.
  3. Navigate to the private key in your file system and select it.
  4. Click Open.

Set up your Validator VM with iN8 Morpheus

Follow the directions below to set up a VM on the Morpheus Cloud Console:



Lemon Installation:

Connect to the VM via SSH

With Terminal

Open terminal and type (replace ‘.ssh/id_rsa’ with the name of your private key file and the location if it is not in the current folder):

ssh -i .ssh/id_rsa ubuntu@<your public IP here>

Accept the cert by typing “yes”.

With Putty

You need to add your private key file to Putty in the proper section and make sure to save the profile so you can reload it in the future when you connect again. Again, Google is your friend. After that, connect in the main window using:

ubuntu@<your public IP here>

It should look something like this:

Document image


Lemon Install Continued

Run the following commands (You can highlight the whole thing and copy it; You paste into the terminal by right-clicking):

This downloads an optimized script written by Kory. We will be modifying it to work with the iN8 Morpheus VM’s.

Document image


Next we need to find out where our volume is located so we can mount it to the right place.

lsblk
Document image


You are looking for the disk that is 1000G, the take note of the name. You will need this in the next step.

nano setup_node.bash

This will open the nano editor program to edit the setup_node.bash file. You need to use your arrow keys to navigate in the editor. You can’t use go places using the mouse.

Document image


You need to use the arrow key to move the cursor and change the 3 “nvme1n1” entries to the name of 1000GB drive.

Document image

Document image


You need to delete the last two lines of the file.

Document image


We are doing this so the script will complete (and we can make sure there are no error) before starting the validator into archive mode and syncing the blockchain). After making the changes, press CTRL-X. It will prompt you to “Save modified buffer?”

Document image


Press 'Y'.

It will then ask you the file name to write. It will be already populated. Just press the “Enter” key.

Document image


Now, enter the following command to start the script:

~/setup_node.bash

This will install and compile everything you need for the validator. It may complain about an ext files system on the volume that you are going to overwrite, just hit 'y'.

It should complete with no error. If you have any errors, make note and bring it to the Validator group for community help.

Document image


From here, we will start the validator into archive mode by running the following command:

~/start_node.bash

It will run for around two hours (as of this writing) to sync the chain.

If you want to monitor the progress (and make sure it is working properly), enter the following command:

tail -f ~/nohup.validator
Document image


You can get back to the command prompt by pressing CTRL-C (this will not stop the validator).

Configure cron job

You need to configure a cron job so your validator starts up in the event of a reboot of the VM.

Run crontab and select option 1, nano

crontab -e
Document image


Use the arrow keys to move the cursor to the end of the file (below all the hash lines)

Document image


Paste the following:

@reboot sleep 30 && /home/ubuntu/start_node.bash
Document image


Press CTRL-X; Y to save buffer; and < Enter > to save it to the file.

Enter the following command:

sudo systemctl enable cron.service
Document image


Create Wallet & Prepare Validator

Open nano.

nano
Document image


Paste the following code into nano.

#!/bin/bash ############################################################### #This script is to create the wallet and deploy the validator# ############################################################### #Check if Validator is already initialized if [ -f /extra/validator ] then echo "Validator file is already there so stoping Deployment" exit 0 fi # Create Validator Wallet echo "Creating your Validator Wallet" echo "Please enter a strong password: - Recommended it be 20 or more characters -" read walletpwd echo "$walletpwd" >> /home/ubuntu/privpwd ~/go-opera/build/opera account new --datadir=/extra/lemon/data --password=/home/ubuntu/privpwd > /extra/validator 2> /extra/validator.errors echo "Wallet Password: $walletpwd" rm -rf /home/ubuntu/privpwd # Create Validator Key echo "Creating Validator Key" echo "Please enter a strong password: - Recommended it be 20 or more characters -" read valkeypwd echo "$valkeypwd" >> /extra/lemon/password ~/go-opera/build/opera validator new --datadir=/extra/lemon/data --password=/extra/lemon/password >> /extra/validator 2>> /extra/validator.errors echo "Validator Key Password: $valkeypwd" chmod 400 /extra/lemon/password # Prep preload.js file wallet_address=`cat /extra/validator | grep 'Public address'` wallet_key=`cat /extra/validator | grep 'Public key'` #Storing password, public key and public address in preload.js password=`cat /extra/lemon/password` publickey=`cat /extra/validator | grep "Public key" | cut -d ":" -f 2 | tr -d " "` publicaddress=`cat /extra/validator | grep "Public address" | cut -d ":" -f 2 | tr -d " "` preload_file=preload.js preload=/extra/${preload_file} asset_base_url="https://assets.allthingslemon.io/validators" # Downloading file and appending the contents to make sure no duplication # echo "Deleting existing file to make sure copy is updated" rm -rf /extra/preload.js # echo "Downloading preload file for ${network}" wget -O "${preload}" "${asset_base_url}/${preload_file}" pass=`echo $password |sed -e 's/^/"/;s/$/"/'` echo -e "\npassword = $pass" >> /extra/preload.js pubkey=`echo $publickey |sed -e 's/^/"/;s/$/"/'` echo "publickey = $pubkey" >> /extra/preload.js pubaddress=`echo $publicaddress |sed -e 's/^/"/;s/$/"/'` echo "wallet = $pubaddress" >> /extra/preload.js echo "tokenstake = 250.00" >> /extra/preload.js if [ -f /extra/validator ] then echo "Validator Deployment is completed" echo echo "Generating Details for you" echo "Wallet Address" echo -e "$wallet_address" echo echo "Wallet Private Key -- Copy this and save to a text editor with .json extention" for privatekey in /extra/lemon/data/keystore/UT*; do cat "$privatekey" done echo echo "Private Key Password: -- WRITE THIS DOWN, DO NOT LOSE" echo "$walletpwd" echo echo -e "$wallet_key" echo echo "Public Key Password -- This has been saved to /extra/lemon/password so you don't need to enter it every time your validator starts." echo "$valkeypwd" echo echo echo "Your Wallet is now ready to fund. Make sure to fund 250.1 LEMX before moving to the next steps." fi

Press CTRL-X Press Y

Save files as:

wallet_setup.sh

At the command prompt run the following:

chmod 744 wallet_setup.sh ./wallet_setup.sh

You will be prompted for a password for your wallet creation. Do yourself a favor and use a password generator with 20 characters and paste it in. You only get one time to enter this, so make sure you have what you want before hitting enter. The password will be displayed to you at the end of this process for you to copy if you didn’t have it copied already.

Document image


You will then be prompted for a password for the Validator Key. Do yourself a favor and use a password generator with 20 characters and paste it in. You only get one time to enter this, so make sure you have what you want before hitting enter. The password will be displayed to you at the end of this process for you to copy if you didn’t have it copied already.

Document image


The process will finish and present you with all your addresses, passwords, keys for you to copy and paste places (this includes the Private Key for you to copy and paste into a text editor)

Copy important stuff With everything listed, take the time to highlight the information, copy and paste it to your local computer.

In particular, copy the Private Key, paste it into a text editor, then save that file with the .json extension.

Fund Wallet

Take your new found wallet information and go fund your wallet with 250.1 LEMX. You cannot proceed further without funding your wallet. Make sure to stake your tokens before moving to the next step.

Complete Validator Setup

This process ONLY works if you used the above scripts to create your wallet. AFTER you have funded your wallet with 250.1 LEMX and staked move to this next step.

Open nano.

nano
Document image


Paste the following code into nano.

#!/bin/bash # This script is for completing validator setup after staking # Check to see if the wallet_setup.sh script was used to create the wallet if [ -f /extra/validator ] then echo "Proceeding" public_key=`cat /extra/validator | grep "^Public key" | sed -e 's/Public key://g' | tr -d " "` validator_id=`/home/ubuntu/go-opera/build/opera attach --preload /extra/preload.js --datadir=/extra/lemon/data --exec '!!abi && !!sfcc ? sfcc.getValidatorID(wallet) : console.log("PROBLEM")'` sed -i 's/startup_mode=1/startup_mode=3/g' /home/ubuntu/start_node.bash sed -i "s/^validator_id=/validator_id=$next/g" /home/ubuntu/start_node.bash sed -i "s/^public_key=/public_key=$public_key/g" /home/ubuntu/start_node.bash sed -i "s/cache=4096/cache=12288/g" /home/ubuntu/start_node.bash echo -e "Finalizing the final Registration Process" echo "Running node in Validator Mode" bash /home/ubuntu/start_node.bash echo "Process is complete" elseif echo "This script is only compatible with the use of the wallet_setup.sh script for wallet creation and validator preparation." exit 0 fi

Press CTRL-X

Press Y

Save files as:

valmode_setup.sh

At the command prompt run the following:

chmod 744 valmode_setup.sh ./valmode_setup.sh

This script will check to make sure the setup files created in with the wallet_setup script are present before proceeding. It will then proceed to setup the validator: get a validator ID, stake the validator, properly config the start_node.bash file (including adjusting the memory cache to the proper recommendation), and restart the validator in validator mode.

*Note: I got the opportunity to test this with a user. For whatever reason, it is not retrieving the validator ID. You will need to manually add the validator ID. When you register your wallet (prior to staking), the dashboard will show you your validator ID. Make note of that. Use nano to edit the start_node.bash file and add the validator ID to the file where it says “validator_id=” After you add that, save the file, the run:

~/start_node.bash

Everything is done. If you want to retrieve your validator id, you can type:

nano start_node.bash

It will be the value listed “validator_id=”

Enjoy!