Staking with Linux on DigitalOcean VPS
Instructions for setting up a HYDRA staking client with DigitalOcean and accessing it with terminal commands
Last updated
Instructions for setting up a HYDRA staking client with DigitalOcean and accessing it with terminal commands
Last updated
DigitalOcean Droplets are Linux-based virtual machines (VMs). They run on top of virtualized hardware. Each Droplet that you create is a new server you can use, either standalone or as used as part of a larger, cloud-based infrastructure. We will be setting one up as a HYDRA staking node/wallet. This same method may be used with other VPS providers.
To access the DigitalOcean Control Panel and create a Droplet, you need a DigitalOcean account. You can create one from the DigitalOcean new account registration page if you don't already have one.
After you log in to the control panel, let's set up some of the security for our VPS. We will create our droplet and then resume the Firewall setup.
It is highly recommended to enable 2FA with Google Authenticator as well as use the SMS backup method. You can find in depth instructions here: https://www.digitalocean.com/docs/accounts/security/2fa/
We will begin by creating and importing SSH keys for logging into our HYDRA node. Please follow THIS guide to create and import SSH keys created specifically for DigitalOcean:
After you log in to the control panel, click the green Create button in the top right or click Droplets on the left panel and clicking 'Create droplet' to open the create menu.
In the create menu, click Droplets to open the Droplet create page. If you don't have any Droplets, the Resources tab displays a large, blue Get Started with a Droplet button, which takes you to the same Droplet create page.
The Droplet create page is where you choose your Droplet's configuration, like its operating system, how much memory it has, and which features to enable (like backups and monitoring). The most popular defaults are pre-selected, so you can scroll to the bottom of the page and create a Droplet immediately, or you can customize any of the options in each section.
Choose the price plan that works for you. Users have been successful staking with the droplet currently listed under 'CPU-Optimized' plan $42/month 4GB Ram, 2 vCPUs, 25 GB NVMe SSD, 4000 GB transfer, however it is recommended to use the higher tier under the 'General Purpose' or 'Memory-Optimized' $63/$84 per month option if it is within your budget, since the performance will be far more stable using the added memory which may be needed down the road as the HYDRA blockchain grows. Few Links here CPU-Optimized | General Purpose | Memory-Optimized
The current absolute minimum for the droplet is the 'CPU-Optimized' $42/month plan 4GB Ram, 2 vCPUs, 25 GB NVMe SSD, 4000 GB transfer.
The recommended specs to use are 16GB Ram, 2 vCPUs, 50 GB NVMe SSD, 4000 GB transfer ($84/month plan) OR the 8GB Ram, 2 vCPUs, 25 GB NVMe SSD, 4000 GB ($63/month plan)
For this guide we will be using version Ubuntu 20.04(LTS) x64 Basic plan for $15/month. Scrolling further down in droplet creation there is the option to choose your datacenter region. This depends on your own personal preference as each area should be similar in stability.
Under authentication it is recommended to select the SSH keys that we have set up earlier. If you have created more than one key you can select them all for use.
Finally click 'Create droplet' to complete the droplet creation. You have the option to select creating system backups if you require it at an extra fee.
Initialization will take a about a minute. Afterwards you will see your new droplet as well as its IP address you will connect to it with. Please take note of the IP address. The address will generally not change and it will be your way of accessing the droplet.
For Testnet, please replace port TCP 3338 with TCP 13333
We'll Continue with our security setup by enabling some custom rules for our Firewall. We'll need to set up the Firewall and allow port TCP/3338 for the node connectivity, as well as allowing Network Time protocol (NTP) to sync the time accurately on port UDP/123. Lastly we will allow port TCP/22 for logging in over SSH using our previously created keys. On the left panel under 'MANAGE' click on 'Networking' and then click 'Firewalls' and then click 'Create Firewall'
Give the new firewall rule a name. We will be adding TCP port 3338 and TCP port 22 as well as UDP port 123 for the network time protocol sync service under Inbound Rules.
Later on as needed we can delete or add back this SSH rule whenever we require access to our node.
Under Type enter SSH and under Protocol enter TCP For Port Range enter 22 as in image below. In the New Rule box add a custom and allow port 3338 by setting to Custom Under Type and under Protocol enter TCP and For Port Range enter 3338. In a second New Rule box add another custom rule and allow port 123 by setting to Custom Under Type and under Protocol enter UDP and For Port Range enter 123.
Below this section under 'Apply to Droplets' you can search for your droplets name (usually it will show your list of droplets by typing in 'ubuntu' and then you can select it clicking on it). Apply the firewall rules to the specific droplet and then click create firewall.
Later after initial setup we can come back here and the Port 22 SSH rule can be deleted for added security and only added back when you want to access the droplet remotely.
You can now log into the VPS with Putty as well as use WinSCP to access files and upload/download your wallet.dat as needed.
You can download Putty from their official site here: https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html
Here is a quick guide to configuring putty. By default the username for your droplet will be root and you will not need a password unless you have set one with your SSH keys setup earlier. If you have already set up your SSH keys you can scroll to 'Configuring Putty' for quick reference on configuring your droplet for access: https://www.bluehost.com/help/article/using-ssh-on-windows-putty
Accessing your server with MobaXterm
We highly recommend MobaXterm as an SSH client. It's just a quantum leap ahead of default Putty and solves lots of issues (e.g copy/paste and or support for multi tab Linux apps such as byobu). Such issues arise often when using SSH with windows and can be really frustrating for new users.
Below is a quick guide to connecting to your droplet using MobaXterm as an alternative to using Putty:
MobaXterm can be downloaded from their official site HERE: https://mobaxterm.mobatek.net/download.html
After installation the MobaXterm program will be in your Windows start menu and can be found by pressing the Windows button and typing 'MobaXterm'. On first initialization you will be prompted to allow the program through the firewall, you can safely click yes and ok to allow it through public networks.
Once the program has started we will click 'Session' and then select 'SSH'
Enter the IP address of your droplet in 'Remote Host' box and then click 'Advanced SSH settings'
Check the box 'Use private key' and select your private key (with .ppk extension) that you have generated earlier. Then click 'Open' and then press 'OK'.
You can now continue with enabling the internal firewall and the installation of the HYDRA wallet below. The next time you start MobaXterm your server will be accessible by simply selecting its IP from the left panel. To learn more about further capabilities such as copying and downloading files as well as Xserver display access, please read the MobaXterm documentation here: https://mobaxterm.mobatek.net/documentation.html#5_1_1
We will enable UFW (Uncomplicated Firewall) and allow ports TCP 22, UDP 123 and TCP 3338. If you have been successful in connecting to your droplet through SSH then you should be looking at a terminal screen. Firstly we will add some rules to the UFW firewall and then enable it. Allow connections to ports 22, 123 and 3338:
Enter these commands on separate lines:
Enable the firewall with this command:
If you have previously generated a wallet.dat file and wish to use it you can place it in /root/.hydra/wallets/ You will need to create this directory if this is a new installation. If you are importing your wallet from a private key then this step is not necessary. Please read documentation about SCP file transfer in MobaXterm: https://mobaxterm.mobatek.net/documentation.html#5_1_1 or by using WinSCP: https://winscp.net/eng/docs/guides if you wish to upload or download files such as your wallet.dat later using a file explorer. It is highly recommended that you ensure backups of wallet.dat are made and are stored encrypted and in a safe location).
You can follow the guide from here for installation: https://docs.hydrachain.org/guide-for-linux
The node will take some time to sync to the latest block.
After successful setup the node will continue to run even after you log out from the shell, providing that the server is not shut down or restarted. If you restart the server you can start up the node again by navigating to ~/Hydra/bin/
and typing ./hydrad -daemon
- this will initialize the daemon with which you can use the cli to send commands; for example If you have already created a wallet and have the private keys you can import them with: ./hydra-cli importprivkey <key>
You can enable staking as well as perform different types of transactions and chain commands. Please see more information about getting information from the cli HERE and full documentation of the available commands HERE.
To see information about your running node you can navigate to ~/Hydra/bin
with command: cd ~/Hydra/bin
and then enter ./hydra-cli getinfo
here you can see which block you are currently synced to as well as wallet version, connections, balances. For information about staking status and more please see HERE for full documentation of wallet commands.
To clear out your terminal history of any stored keys and passwords from memory use: history -c && history -w
At this point your wallet is hopefully running and set up to start staking. The wallet.dat and blockchain date is stored in /root/.hydra/
or /home/username/.hydra/
depending on your setup. It is recommended to lock your wallet with a passphrase from the /Hydra/bin/
directory:
We can unlock only for staking when it is left running on any system or VPS:
If you lock the wallet you will then need to enter the passphrase to use the wallet to send out transactions. The following command unlocks for five minutes:
You can view your Coin balance and amount currently staked with the following command:
This is slightly involved, first we'll need to find out the HEX equivalent of our address. We can do this through the cli with this command:
We can then call the contract with the "getbalance" identifier appended, which is 70a08231
and replacing the last part <YOURHEXADDRESS>
with your own hex address here:
Finally convert the "output" section of the response from hex to decimal to arrive at your LOC balance.
Below is a full example:
Keep in mind to adjust for 8 decimal places. Above balance is 64,172.22773141
To see expected time enter the following command:
Note below the section "expectedtime".
The "expectedtime" can be converted to human readable format using the following command (replace 1254588
with your expectedtime value:
For further instructions on operating the node and unlocking the wallet for staking, please see the documentation here: https://docs.hydrachain.org/essentials/hydra-wallet-commands
If your node is running and staking and you have imported the keys where your HYDRA coins are stored, you may now choose to delete the SSH rule from the digital ocean firewall section and add it back at a later time when you wish to access the Droplet again - This will add an extra layer of security as there is no way for anyone to access your server without two factor authentication with DigitalOcean and manually reopening the port.
You can visit explorer.hydrachain.org to check on the staking status of your node by searching for your address and seeing how many blocks have been mined as well as your balances and transactions. Good luck staking!