Install IPFS

Guide to installing ipfs on a public ip address with firewall and seperate user for ipfs daemon

This guide describes commands entered in the terminal window. If you are in a desktop enviornment, open a terminal window


Install Debian Linux

There are plenty of guides on this


Become Root

If you are not root, become root by executing the command: su

$ su
Password: <enter password for root here>
# _

The commands in this guide assume you are running as root unless otherwise noted.


Install IPFS

In case you don't already have a couple packages, run these commands:

apt install -y apt-transport-https
apt install -y curl

The easist way I have found currently to install IPFS and keep it updated is to use the package maintained by "siderus"

Incorporated into this document below, the blog post on diong this is currently located here: https://blog.siderus.io/how-to-get-ipfs-on-ubuntu-debian-linux-d7920c1a42b7

To use it you need to run the following commands from your terminal:

curl https://get.siderus.io/key.public.asc | apt-key add -
echo "deb https://get.siderus.io/ apt/" | tee -a /etc/apt/sources.list.d/siderus.list
apt update

Then install

apt install ipfs

Install a firewall

If running behind a NAT router, or are comfortable running without a firewall you can skip this section.

If you already have a firewall on this machine, do not install UFW on top of it, but you should make sure that incoming traffic to port 4001 is allowed

Install Uncomplicated Firewall (UFW)

apt install ufw

Add firewall rule for IPFS node communication

ufw allow 4001/tcp
Rules updated
Rules updated (v6)

IMPORTANT:Add other firewall rules if needed

If you use SSH to access your server, be sure to add an allow rule for SSH before activating the firewall

ufw allow 22/tcp
Rules updated
Rules updated (v6)

Enable the firewall

ufw enable
Command may disrupt existing ssh connections. Proceed with operation (y|n)? y
Firewall is active and enabled on system startup

Add a user account

Use the following command to add a user called IPFS, assigning a password that you will remember, and accepting all the defaults for the remaing question by pressing <ENTER>

adduser ipfs
Adding user `ipfs' ...
Adding new group `ipfs' (1001) ...
Adding new user `ipfs' (1001) with group `ipfs' ...
Creating home directory `/home/ipfs' ...
Copying files from `/etc/skel' ...
Enter new UNIX password: <enter password for new user here>
Retype new UNIX password: <enter password for new user here>
passwd: password updated successfully
Changing the user information for ipfs
Enter the new value, or press ENTER for the default
Full Name []: <ENTER>
Room Number []: <ENTER>
Work Phone []: <ENTER>
Home Phone []: <ENTER>
Other []: <ENTER>
Is the information correct? [Y/n] y

Switch users and initialize IPFS

use the following command to switch to being the new ipfs user

su - ipfs

Then initialize the IPFS repo with the following command:

ipfs init
Then type exit to get back to the root account

Other tweaks

Increase Storage Max

Use this command or the editor of your choice to edit the IPFS config file:

nano ~ipfs/.ipfs/config

In the below example, the Storage Max has been increased to 300GB. You may want more or less depending on what you plan to host.

  "Datastore": {
    "StorageMax": "300GB",
    "StorageGCWatermark": 90,
    "GCPeriod": "1h",
    "Spec": {
      "mounts": [
        {

and Save. In nano, press <CTRL>+X, and then y and <ENTER>


Create a service to keep IPFS running all the time

Create a service file using nano, or the editor of your choice

nano /etc/systemd/system/ipfs.service
Paste the following code into the editor
[Unit]
Description=IPFS daemon
After=network.target

[Service]
User=ipfs
LimitNOFILE=65536
Environment="IPFS_PATH=/home/ipfs/.ipfs"
ExecStart=/usr/bin/ipfs daemon --enable-namesys-pubsub
Restart=on-failure

[Install]
WantedBy=multi-user.target

and Save. In nano, press <CTRL>+X, and then y and <ENTER>

To start the service:

systemctl start ipfs

Then, if that seemed to work correctly, install the service so that it will start at every bootup with the following command:

systemctl enable ipfs
Created symlink /etc/systemd/system/multi-user.target.wants/ipfs.service → /etc/systemd/system/ipfs.service.