IPFS (kubo) in WSL

· macaylamarvelous81's blog

Let's setup IPFS CLI in WSL.

In this blog post, I will go over how I setup the kubo cli for IPFS on a Debian WSL distro. It will also be a user service on systemd, so it will start automatically and keep running.

Setup genie #

First, I setup genie with the help of this gist. With the help of genie, we can use systemd in our terminal later.

Install kubo #

Then, I installed the kubo tool from dist.ipfs.tech.

 1$ TMP=$(mktemp -d)
 2$ cd $TMP
 3$ wget https://dist.ipfs.tech/kubo/v0.17.0/kubo_v0.17.0_linux-amd64.tar.gz
 4  'kubo_v0.17.0_linux-amd64.tar.gz' saved
 5$ tar -xvzf kubo_v0.17.0_linux-amd64.tar.gz
 6  kubo/LICENSE
 7  kubo/LICENSE-APACHE
 8  kubo/LICENSE-MIT
 9  kubo/README.md
10  kubo/install.sh
11  kubo/ipfs
12$ cd kubo
13$ ./install.sh
14  Moved ./ipfs to ~/.local/bin
15$ cd ~
16$ rm -r $TMP

Since I ran install.sh as a user and not root, kubo was installed to only my user instead of globally on the system.

Create kubo service #

Then, I was able to make kubo into a service for systemd.

1$ mkdir -p ~/.config/systemd/user
2$ nano ~/.config/systemd/user/ipfs.service
1[Unit]
2Description=IPFS daemon
3
4[Service]
5ExecStart=~/.local/bin/ipfs daemon
6Restart=on-failure
7
8[Install]
9WantedBy=default.target

Finally, I enabled my user to linger and enabled the service using systemctl:

1# loginctl enable-linger [user]
2$ systemctl --user enable ipfs
3$ systemctl --user start ipfs

Finished #

Now, IPFS is installed and the daemon is running. I can add and get from IPFS, and even publish IPNS names using the ipfs command. If I close the terminal, the daemon will still continue running.