2024-04-29 17:49:02 +00:00
< h1 > IPFS on a Full VM< / h1 >
< h2 > Table of Contents< / h2 >
- [Introduction ](#introduction )
- [Deploy a Full VM ](#deploy-a-full-vm )
- [Create a Root-Access User ](#create-a-root-access-user )
- [Set a Firewall ](#set-a-firewall )
- [Additional Ports ](#additional-ports )
- [Install IPFS ](#install-ipfs )
- [Set IPFS ](#set-ipfs )
- [Final Verification ](#final-verification )
- [Questions and Feedback ](#questions-and-feedback )
***
## Introduction
In this ThreeFold guide, we explore how to set an IPFS node on a Full VM using the ThreeFold Playground.
## Deploy a Full VM
We start by deploying a full VM on the ThreeFold Playground.
* Go to the [Threefold Playground ](https://playground.grid.tf/#/ )
* Deploy a full VM (Ubuntu 20.04) with an IPv4 address and at least the minimum specs
* IPv4 Address
* Minimum vcores: 1vcore
* Minimum MB of RAM: 1024GB
* Minimum storage: 50GB
* After deployment, note the VM IPv4 address
* Connect to the VM via SSH
2024-05-14 17:04:07 +00:00
```
2024-04-29 17:49:02 +00:00
ssh root@VM_IPv4_address
```
## Create a Root-Access User
We create a root-access user. Note that this step is optional.
* Once connected, create a new user with root access (for this guide we use "newuser")
2024-05-14 17:04:07 +00:00
```
2024-04-29 17:49:02 +00:00
adduser newuser
```
* You should now see the new user directory
2024-05-14 17:04:07 +00:00
```
2024-04-29 17:49:02 +00:00
ls /home
```
* Give sudo capacity to the new user
2024-05-14 17:04:07 +00:00
```
2024-04-29 17:49:02 +00:00
usermod -aG sudo newuser
```
* Switch to the new user
2024-05-14 17:04:07 +00:00
```
2024-04-29 17:49:02 +00:00
su - newuser
```
* Create a directory to store the public key
2024-05-14 17:04:07 +00:00
```
2024-04-29 17:49:02 +00:00
mkdir ~/.ssh
```
* Give read, write and execute permissions for the directory to the new user
2024-05-14 17:04:07 +00:00
```
2024-04-29 17:49:02 +00:00
chmod 700 ~/.ssh
```
* Add the SSH public key in the file **authorized_keys** and save it
2024-05-14 17:04:07 +00:00
```
2024-04-29 17:49:02 +00:00
nano ~/.ssh/authorized_keys
```
* Exit the VM
2024-05-14 17:04:07 +00:00
```
2024-04-29 17:49:02 +00:00
exit
```
* Reconnect with the new user
2024-05-14 17:04:07 +00:00
```
2024-04-29 17:49:02 +00:00
ssh newuser@VM_IPv4_address
```
## Set a Firewall
We set a firewall to monitor and control incoming and outgoing network traffic. To do so, we will define predetermined security rules. As a firewall, we will be using [Uncomplicated Firewall ](https://wiki.ubuntu.com/UncomplicatedFirewall ) (ufw).
For our security rules, we want to allow SSH, HTTP and HTTPS (443 and 8443).
We thus add the following rules:
* Allow SSH (port 22)
2024-05-14 17:04:07 +00:00
```
2024-04-29 17:49:02 +00:00
sudo ufw allow ssh
```
* Allow port 4001
2024-05-14 17:04:07 +00:00
```
2024-04-29 17:49:02 +00:00
sudo ufw allow 4001
```
* To enable the firewall, write the following:
2024-05-14 17:04:07 +00:00
```
2024-04-29 17:49:02 +00:00
sudo ufw enable
```
* To see the current security rules, write the following:
2024-05-14 17:04:07 +00:00
```
2024-04-29 17:49:02 +00:00
sudo ufw status verbose
```
You now have enabled the firewall with proper security rules for your IPFS deployment.
### Additional Ports
We provided the basic firewall ports for your IPFS instance. There are other more advanced configurations possible.
If you want to access your IPFS node remotely, you can allow **port 5001** . This will allow anyone to access your IPFS node. Make sure that you know what you are doing if you go this route. You should, for example, restrict which external IP address can access port 5001.
If you want to run your deployment as a gateway node, you should allow **port 8080** . Read the IPFS documentation for more information on this.
If you want to run pubsub capabilities, you need to allow **port 8081** . For more information, read the [IPFS documentation ](https://blog.ipfs.tech/25-pubsub/ ).
## Install IPFS
We install the [IPFS Kubo binary ](https://docs.ipfs.tech/install/command-line/#install-official-binary-distributions ).
* Download the binary
2024-05-14 17:04:07 +00:00
```
2024-04-29 17:49:02 +00:00
wget https://dist.ipfs.tech/kubo/v0.24.0/kubo_v0.24.0_linux-amd64.tar.gz
```
* Unzip the file
2024-05-14 17:04:07 +00:00
```
2024-04-29 17:49:02 +00:00
tar -xvzf kubo_v0.24.0_linux-amd64.tar.gz
```
* Change directory
2024-05-14 17:04:07 +00:00
```
2024-04-29 17:49:02 +00:00
cd kubo
```
* Run the install script
2024-05-14 17:04:07 +00:00
```
2024-04-29 17:49:02 +00:00
sudo bash install.sh
```
* Verify that IPFS Kubo is properly installed
2024-05-14 17:04:07 +00:00
```
2024-04-29 17:49:02 +00:00
ipfs --version
```
## Set IPFS
We initialize IPFS and run the IPFS daemon.
* Initialize IPFS
2024-05-14 17:04:07 +00:00
```
2024-04-29 17:49:02 +00:00
ipfs init --profile server
```
* Increase the storage capacity (optional)
2024-05-14 17:04:07 +00:00
```
2024-04-29 17:49:02 +00:00
ipfs config Datastore.StorageMax 30GB
```
* Run the IPFS daemon
2024-05-14 17:04:07 +00:00
```
2024-04-29 17:49:02 +00:00
ipfs daemon
```
* Set an Ubuntu systemd service to keep the IPFS daemon running after exiting the VM
2024-05-14 17:04:07 +00:00
```
2024-04-29 17:49:02 +00:00
sudo nano /etc/systemd/system/ipfs.service
```
* Enter the systemd info
2024-05-14 17:04:07 +00:00
```
2024-04-29 17:49:02 +00:00
[Unit]
Description=IPFS Daemon
[Service]
Type=simple
ExecStart=/usr/local/bin/ipfs daemon --enable-gc
Group=newuser
Restart=always
Environment="IPFS_PATH=/home/newuser/.ipfs"
[Install]
WantedBy=multi-user.target
```
* Enable the service
2024-05-14 17:04:07 +00:00
```
2024-04-29 17:49:02 +00:00
sudo systemctl daemon-reload
sudo systemctl enable ipfs
sudo systemctl start ipfs
```
* Verify that the IPFS daemon is properly running
2024-05-14 17:04:07 +00:00
```
2024-04-29 17:49:02 +00:00
sudo systemctl status ipfs
```
## Final Verification
We reboot and reconnect to the VM and verify that IPFS is properly running as a final verification.
* Reboot the VM
2024-05-14 17:04:07 +00:00
```
2024-04-29 17:49:02 +00:00
sudo reboot
```
* Reconnect to the VM
2024-05-14 17:04:07 +00:00
```
2024-04-29 17:49:02 +00:00
ssh newuser@VM_IPv4_address
```
* Check that the IPFS daemon is running
2024-05-14 17:04:07 +00:00
```
2024-04-29 17:49:02 +00:00
ipfs swarm peers
```
## Questions and Feedback
If you have any questions or feedback, please let us know by either writing a post on the [ThreeFold Forum ](https://forum.threefold.io/ ), or by chatting with us on the [TF Grid Tester Community ](https://t.me/threefoldtesting ) Telegram channel.