IPFS Node on Raspberry Pi 3

Photo by NASA on Unsplash

What you will need

Steps

Flash SD card with OS

Note: If you need more help — https://www.raspberrypi.org/documentation/installation/installing-images/README.md

Setup WiFi and SSH

Note: If you are directly connecting the pi via an ethernet cable, you can skip this section.

iwconfig
wpa_passphrase "MyWiFiESSID" "MyWiFiPassword" >> wpa_supplicant.conf

Two things are happening here:

wpa_passphrase "MyWiFiESSID" "MyWiFiPassword" will create a network profile with your password replaced by a token so that it is not saved as plain text.

>> wpa_supplicant.conf will add the network profile to your configuration file.

sudo nano wpa_supplicant.conf
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=IN
network={
ssid="MyWiFiESSID"
#psk="MyWiFiPassword" #Delete this line
psk=131e1e221f6e06e3911a2d11ff2fac9182665c004de85300f9cac208a6a80531
}

More info can be found here — https://www.raspberrypi.org/documentation/configuration/wireless/headless.md

touch ssh

More info can be found here — https://www.raspberrypi.org/documentation/remote-access/ssh/README.md

Connect to Pi using SSH

ssh pi@<pi-ip-address>

I used a Linux machine to connect to my pi, but for Windows users, you will need to install an additional tool — Putty, in order to SSH into another computer.

Note: For more information on setting up SSH — https://www.raspberrypi.org/documentation/remote-access/ssh/README.md

Static IP address

ifconfig
sudo nano /etc/dhcpcd.conf
interface eth0static ip_address=192.168.0.100/24
static routers=192.168.0.1
static domain_name_servers=192.168.0.1
interface wlan0static ip_address=192.168.0.100/24
static routers=192.168.0.1
static domain_name_servers=192.168.0.1
sudo update
sudo upgrade
sudo reboot

Note: If you want to connect to your pi using your phone, you can use JuiceSSH. Make sure you are on the same network as your pi in order for it to work.

Install IPFS

uname -m

Note: For a complete listing of the ARM architecture and what bit is your pi — https://en.wikipedia.org/wiki/ARM_architecture

$ wget http://dist.ipfs.io.ipns.localhost:8080/go-ipfs/v0.9.0/go-ipfs_v0.9.0_linux-arm.tar.gz
$ tar -xvzf go-ipfs_v0.9.0_linux-arm.tar.gz
$ cd go-ipfs
$ sudo bash install.sh
$ ipfs --version

Note: Complete IPFS installation instructions — http://docs.ipfs.io.ipns.localhost:8080/install/command-line/#official-distributions

Configure IPFS node

ipfs init
sudo nano /etc/systemd/system/ipfs.service
[Unit] 
Description=IPFS Daemon
After=network.target
[Service]
Type=simple ExecStart=/usr/local/bin/ipfs daemon --migrate=true --enable-gc=true
User=user
Restart=on-failure
[Install]
WantedBy=default.target
sudo systemctl start ipfs
ipfs swarm peers
sudo nano ~/.ipfs/config
"Datastore": {
"StorageMax": "10GB",
...

Note: More information on configuring an ipfs node can be found here — http://docs.ipfs.io/how-to/configure-node/

Adding and Pinning your files to the node

echo "Hello World" >> hello.txt
ipfs add hello.txt
added QmWATWQ7fVPP2EFGu71UkfnqhYXDYH566qy47CnJDgvs8u hello.txt
12 B / 12 B [=========================================================] 100.00%

To add more than text files to your node, you can use Filezilla to copy across files to your pi and then add/pin them.

Note: All command line commands can be found here — http://docs.ipfs.io/reference/cli/

Hope this guide was useful and if there are any comments/edits/problems/questions, please do ask away :) All feedback is welcome. Feel free to ask any questions via Twitter as well — https://twitter.com/neha_m25

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store