Part 1 - Server Setup
This section will help you set up and configure a server to prepare it for running a Pocket node.
Last updated
This section will help you set up and configure a server to prepare it for running a Pocket node.
Last updated
The first thing you’ll need to run a Pocket node is a server. For this guide, we’ll be using a virtual machine on the cloud service, but you can use any cloud service you like, or run a server of your own.
Let’s start by creating a Linode instance (a virtual machine).
To create a Linode instance ("Linode"), do the following:
Sign up for a account and log in.
Create a new Linode with the following specifications:
Image / Distribution: Ubuntu 20.04 LTS
Region: Atlanta, GA
Linode Plan: Dedicated 16 GB - 8 CPU, 320 GB Storage, 16 GB RAM
Linode Label: pokt001
Wait for the Linode to be created and show up as running in the web interface.
The Pocket blockchain is large and growing quickly, and the snapshot we’ll be downloading in a later step is too large to fit on this Linode instance.
Because of this, we’ll need to create a secondary storage volume. Our recommendation is at least 1.5TB to begin with. But as you'll need more space in the future, you may opt for a larger volume or one that can be increased later.
In your Linode account, click Volumes and then Create Volume.
Create a volume with the following specifications:
Label: poktuserdir
Size: 1500GB
Region: [Same as your instance]
Linode: pokt001
Pocket nodes require a DNS name. DNS names are used to map an IP address to more human-friendly names. So rather than referencing a server with an address like 134.23.153.21
we can use a name like pokt001.pokt.run
.
Specifically, you’ll need to add an A
record for the domain name. For the exact steps, consult the DNS documentation for your provider. Then create a record with the following information:
Name: pokt001
Type: A
Value: [Linode_IP_Address]
TTL: 300
After setting up your DNS record, wait a few minutes for it to propagate. Then use the following command to check that the DNS record is working:
You should see a response that looks something like this:
If the IP address matches the IP address of your Linode instance, you’re all set!
SSH is a secure way to connect to your Linode instance from a remote machine, like your local computer. We’ll be using SSH to complete the rest of the setup process.
If your local computer uses Linux, Windows 10 or later, or is a Mac you can SSH into your node by doing the following:
Open a terminal.
SSH into your node using the following command:
You’ll be asked for your password. This is the root password that you set when you created your Linode.
At this point you should be logged into your node as the root
user.
In a previous step, we set the DNS name for the node. Now we’ll use the same name for the hostname on the server.
To set the server hostname do as follows:
Open the /etc/hostname
file with the following command:
Change the localhost
value to the hostname of your node (for example, pokt001.pokt.run
).
Save the file with Ctrl+O
and then Enter
.
Exit nano with Ctrl+X
.
Reboot the server with the following command:
Wait for the server to reboot then SSH back in as the root
user before continuing.
For security reasons do not to use the root
user. Instead, create a new user and add this user to the sudo
group.
To do so, enter the following commands:
Create a new user named pocket
, add it to the sudo
group, and set the default shell to bash
. If you want to specify the location of the home directory, you can use the -d
option followed by the path to the home directory:
For the rest of this guide, we’ll be using the pocket
user. So now that the pocket
user has been created, you can switch from the root
to the pocket
user with the following command:
Next we want to mount the secondary storage volume that we created in a previous step.
Verify that the volume is attached to your instance.
Create a new partition. If the previous command shows a file path different from /dev/sdc
, use that instead in the commands below:
Create a new mount point:
Mount the new partition:
Verify that the partition was created by running the following command:
Set the volume to be mounted automatically. Open /etc/fstab
:
Add the following line to the bottom of the file:
Save the file with Ctrl+O
and then Enter
.
Exit nano with Ctrl+X
.
Many Pocket commands assume a data directory path of ~/.pocket
. While it is possible to specify a different data directory with every command, it is much easier to change the location of the pocket
user home directory. For this tutorial, we will be setting the Pocket data directory at /mnt/data/.pocket
.
To change the home directory of the pocket
user:
While not required, using an SSH key provides a more secure means of accessing your server.
Since an SSH key is truly random, it eliminates the pitfalls that can come with user-generated passwords, and using one to log in to your server removes the ability for credentials to be sniffed in the login process.
One important thing to understand is that without access to the SSH key you won’t be able to log into your node. If you intend on accessing your node from multiple computers, it’s recommended that you repeat the Generate Key and Upload Key steps from each computer from which you intend to access your node before proceeding to the Disable Root Login and Password Authentication step.
Log Out
At the terminal you’ll need to enter the logout
command twice. The first logout
logs you out of the pocket
user and back to the root user, and the second logout
logs you out of the server and back to your terminal.
Generate Key
Next, we’ll generate an SSH key. To do that you’ll run the ssh-keygen
command. You’ll be prompted to specify the file to which you want to save the key and to create a password. While a password is optional, we recommend it as it will secure your server in the event that someone accesses your key. To create the key, do the following:
Run the ssh-keygen
command:
Enter file in which to save the key (~/.ssh/id_rsa
).
Enter a passphrase (empty for no passphrase).
Enter same passphrase again.
The results should look similar to the following:
Upload Key
Now we’re going to upload the key so that we can use it to log into the pocket
user. If you chose a different path for the SSH key, use it to replace ~/.ssh/id_rsa.
Disable Root Login and Password Authentication
We’re now going to configure SSH to no longer allow root logins, and to disallow any password-based login attempts. This means that without access to the SSH key for the pocket
user, you won't be able to log into the server.
First we’ll need to log back into the server:
From there, we’ll need to open the /etc/ssh/sshd_config
and change the default configuration:
Once in the file, we’ll need to make the following line changes:
#PermitRootLogin prohibit-password
-> PermitRootLogin no
#PubkeyAuthentication yes
-> PubkeyAuthentication yes
#PasswordAuthentication yes
-> PasswordAuthentication no
Once changed, Ctrl-O
followed by Enter
will save the changes, and Ctrl-X
will exit nano back to the terminal.
Then we’ll need to restart the SSH server for these changes to take effect:
Verify Everything Works
The last step is to log out of the server and try logging back in. If you’re no longer prompted for a password (assuming you did not set a password when creating the SSH key), then everything is working as expected.
That’s it for the server setup! Continue on to install the necessary software.
Now that the Linode instance is created and running, you’ll need to set up a DNS () record that points to the IP address of the Linode instance.
Now that we've set up a DNS record, we will use SSH () to log in to our server and continue the setup process.
If you’re using an older version of Windows that doesn't have a built-in SSH client, you might need to install or a different SSH client.
Windows users may not have access to this command. If you don't have access to a Bash shell, you can use PowerShell to mimic this command.