{"id":5758,"date":"2021-06-01T23:12:58","date_gmt":"2021-06-01T23:12:58","guid":{"rendered":"https:\/\/www.geekdecoder.com\/?p=5758"},"modified":"2021-06-01T23:12:58","modified_gmt":"2021-06-01T23:12:58","slug":"install-ipfs-on-debian","status":"publish","type":"post","link":"https:\/\/www.qbytes.cloud\/index.php\/2021\/06\/01\/install-ipfs-on-debian\/","title":{"rendered":"Install IPFS on Debian 10 Buster"},"content":{"rendered":"<p><a href=\"https:\/\/qbytes.cloud\/wp-content\/uploads\/2021\/06\/webui.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-5945\" src=\"https:\/\/qbytes.cloud\/wp-content\/uploads\/2021\/06\/webui-1024x475.png\" alt=\"\" width=\"900\" height=\"417\" srcset=\"https:\/\/www.qbytes.cloud\/wp-content\/uploads\/2021\/06\/webui-1024x475.png 1024w, https:\/\/www.qbytes.cloud\/wp-content\/uploads\/2021\/06\/webui-300x139.png 300w, https:\/\/www.qbytes.cloud\/wp-content\/uploads\/2021\/06\/webui-768x356.png 768w, https:\/\/www.qbytes.cloud\/wp-content\/uploads\/2021\/06\/webui-1536x713.png 1536w, https:\/\/www.qbytes.cloud\/wp-content\/uploads\/2021\/06\/webui.png 1896w\" sizes=\"auto, (max-width: 900px) 100vw, 900px\" \/><\/a>Installing IPFS through the command-line is handy if you plan on building applications and services on top of an IPFS node. This method is also useful if you&#8217;re setting up a node without a user interface, usually the case with remote servers or virtual machines. Using IPFS through the command-line allows you to do everything that IPFS Desktop can do, but at a more granular level since you can specify which commands to run.<\/p>\n<p>You can install as root or in Debian add or modify a user for sudo.<\/p>\n<p>By default sudo is not installed on Debian, but you can install it. First login as root.<br \/>\nInstall sudo by running:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\"># apt-get install sudo -y\n<\/pre>\n<p>Add a user ipfs ( or use one of your own users).<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\"># adduser ipfs\nAdding user `ipfs&#039; ...\nAdding new group `ipfs&#039; (1000) ...\nAdding new user `ipfs&#039; (1000) with group `ipfs&#039; ...\nCreating home directory `\/home\/ipfs&#039; ...\nCopying files from `\/etc\/skel&#039; ...\nNew password:\nRetype new password:\npasswd: password updated successfully\nChanging the user information for ipfs\nEnter the new value, or press ENTER for the default\n        Full Name &#x5B;]: IPFS\n        Room Number &#x5B;]:\n        Work Phone &#x5B;]:\n        Home Phone &#x5B;]:\n        Other &#x5B;]:\nIs the information correct? &#x5B;Y\/n] y\n<\/pre>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\"># usermod -aG sudo ipfs\n<\/pre>\n<p>Make sure your sudoers file have sudo group added. Run:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\"># visudo\n<\/pre>\n<p>Allow members of group sudo to execute any command<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">%sudo   ALL=(ALL:ALL) ALL\n<\/pre>\n<p>Copy ssh keys to ipfs user from root(optional step)<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\"># cp -r .ssh\/ \/home\/ipfs\/\n<\/pre>\n<p>Set permissions<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\"> # chown -R ipfs:ipfs \/home\/ipfs\/.ssh\/\n<\/pre>\n<p>You need to relogin or reboot device completely for changes to take effect.<\/p>\n<p>IPFS Install<br \/>\nLogin as the IPFS user.<\/p>\n<p>Download the Linux binary from dist.ipfs.io<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">$ wget https:\/\/dist.ipfs.io\/go-ipfs\/v0.8.0\/go-ipfs_v0.8.0_linux-amd64.tar.gz\n<\/pre>\n<p>Unzip the file:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">$ tar xvfz go-ipfs_v0.8.0_linux-amd64.tar.gz\ngo-ipfs\/install.s\ngo-ipfs\/ipfs\ngo-ipfs\/LICENSE\ngo-ipfs\/LICENSE-APACHE\ngo-ipfs\/LICENSE-MIT\ngo-ipfs\/README.md\n\n<\/pre>\n<p>Move into the go-ipfs folder and run the install script:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">$ cd go-ipfs\n<\/pre>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">$ sudo .\/install.sh\nMoved .\/ipfs to \/usr\/local\/bin\n<\/pre>\n<p>Move to HOME<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">cd ..\n<\/pre>\n<p>Test that IPFS has installed correctly:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">$ ipfs --version\nipfs version 0.8.0\n<\/pre>\n<p>Initialize the repository<\/p>\n<p>ipfs stores all its settings and internal data in a directory called the repository. Before using IPFS for the first time, you\u2019ll need to initialize the repository with the &#8220;ipfs init&#8221; command. There are 2 was to Initialize. Local and Data Center Installations. If you are in a Data Center skip to the Datacenter Installation below.<\/p>\n<p>Local Installation (Only for local installations):<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">$ IPFS_PATH=~\/.ipfs ipfs init\n<\/pre>\n<p>Datacenter Installation:<br \/>\nIf you are running on a server in a data center, you should initialize IPFS with the server profile. Doing so will prevent IPFS from creating a lot of data center-internal traffic trying to discover local nodes:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">$ IPFS_PATH=~\/.ipfs ipfs init --profile server\ngenerating ED25519 keypair...done\npeer identity: 12D3KooWKQn2n8Yee75qJqUHAc6cpfZypby2qhczWhXYx2k4FEtM\ninitializing IPFS node at \/home\/username\/.ipfs\nto get started, enter:\n\n        ipfs cat \/ipfs\/QmQPeNsJPyVWPFDVHb77w8G42Fvo15z4bG2X8D2GhfbSXc\/readme\n<\/pre>\n<p>The hash after peer identity is your node\u2019s ID and will be different from the one shown in the above output. Other nodes on the network use it to find and connect to you. You can run ipfs id at any time to get it again if you need it.<\/p>\n<p>Now, run the command in the output of ipfs init. The one that looks like this&#8230;<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">$ ipfs cat \/ipfs\/QmQPeNsJPyVWPFDVHb77w8G42Fvo15z4bG2X8D2GhfbSXc\/readme\n<\/pre>\n<p>You should see something like this:<br \/>\n<a href=\"https:\/\/qbytes.cloud\/wp-content\/uploads\/2021\/06\/ipfs.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-5778\" src=\"https:\/\/qbytes.cloud\/wp-content\/uploads\/2021\/06\/ipfs-300x255.png\" alt=\"\" width=\"300\" height=\"255\" srcset=\"https:\/\/www.qbytes.cloud\/wp-content\/uploads\/2021\/06\/ipfs-300x255.png 300w, https:\/\/www.qbytes.cloud\/wp-content\/uploads\/2021\/06\/ipfs.png 614w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>You can explore other objects in the repository. In particular, the quick-start directory which shows example commands to try:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">$ ipfs cat \/ipfs\/QmQPeNsJPyVWPFDVHb77w8G42Fvo15z4bG2X8D2GhfbSXc\/quick-start\n<\/pre>\n<p>Take your node online<\/p>\n<p>Option 1<\/p>\n<p>Once you&#8217;re ready to join your node to the public network, run the ipfs daemon <strong>in another terminal<\/strong> and wait for all three lines below to appear to know that your node is ready. This is a way to manually start it. See below to have the service set up to start automatically.<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">$ IPFS_PATH=~\/.ipfs ipfs daemon\nInitializing daemon...\ngo-ipfs version: 0.9.0\nRepo version: 11\nSystem version: amd64\/linux\nGolang version: go1.15.8\nAPI server listening on \/ip4\/127.0.0.1\/tcp\/5001\nWebUI: http:\/\/127.0.0.1:5001\/webui\nGateway (readonly) server listening on \/ip4\/1127.0.0.1\/tcp\/8080\nDaemon is ready\n<\/pre>\n<p>Make a note of the TCP ports you receive. If they are different, use yours in the commands below.<\/p>\n<p>Now, switch back to your original terminal. If you\u2019re connected to the network, you should be able to see the IPFS addresses of your peers when you run:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">$ ipfs swarm peers\n<\/pre>\n<p>Option 2<br \/>\nIt would be better to start IPFS daemon as a service instead of the terminal attached process.<br \/>\nYou can create a service so that the daemon runs automatically. Edit user profile for setting env variables:<\/p>\n<p>Create systemctl service for ipfs:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">$ sudo nano \/etc\/systemd\/system\/ipfs.service\n<\/pre>\n<p>Add the following (Change User and Group Accordingly):<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">&#x5B;Unit]\nDescription=IPFS Daemon\nAfter=syslog.target network.target remote-fs.target nss-lookup.target\n\n&#x5B;Service]\nType=simple\nExecStart=\/usr\/local\/bin\/ipfs daemon --enable-namesys-pubsub\nUser=ipfs\n&#x5B;Install]\nWantedBy=multi-user.target\n<\/pre>\n<p>restart systemctl daemon so it finds new service:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">$ sudo systemctl daemon-reload\n<\/pre>\n<p>tell systemctl that ipfs should be started on startup:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">$ sudo systemctl enable ipfs\n<\/pre>\n<p>start ipfs:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">$ sudo systemctl start ipfs\n<\/pre>\n<p>check status:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">$ sudo systemctl status ipfs\n<\/pre>\n<p>should see something like<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\u25cf ipfs.service - ipfs daemon\n   Loaded: loaded (\/lib\/systemd\/system\/ipfs.service; enabled; vendor preset: enabled)\n   Active: active (running) since Wed 2019-08-28 20:38:04 UTC; 4s ago\n Main PID: 30133 (ipfs)\n    Tasks: 9 (limit: 4915)\n   CGroup: \/system.slice\/ipfs.service\n           \u2514\u250030133 \/usr\/local\/bin\/ipfs daemon --enable-gc\n\nipfs&#x5B;30133]: Swarm listening on \/ip4\/127.0.0.1\/tcp\/4001\nipfs&#x5B;30133]: Swarm listening on \/ip4\/172.31.43.10\/tcp\/4001\nipfs&#x5B;30133]: Swarm listening on \/ip6\/::1\/tcp\/4001\nipfs&#x5B;30133]: Swarm listening on \/p2p-circuit\nipfs&#x5B;30133]: Swarm announcing \/ip4\/127.0.0.1\/tcp\/4001\nipfs&#x5B;30133]: Swarm announcing \/ip6\/::1\/tcp\/4001\nipfs&#x5B;30133]: API server listening on \/ip4\/127.0.0.1\/tcp\/5001\nipfs&#x5B;30133]: WebUI: http:\/\/127.0.0.1:5001\/webui\nipfs&#x5B;30133]: Gateway (readonly) server listening on \/ip4\/127.0.0.1\/tcp\/80\nipfs&#x5B;30133]: Daemon is ready\n<\/pre>\n<p>How to see documents from other that a local web URL.<\/p>\n<p>By default, the files are only visible for a browser at localhost. To change this, change the gateway and restart the daemon.<\/p>\n<p>Make gateway publicly accessible. This allows you and everyone to view files.<\/p>\n<p>If you want to, you can make your IPFS gateway and webui publicly accessible (Note: This should not be done unless locked down with a firewall rule restricting access). Change gateway configuration to listen on all available IP addresses.<\/p>\n<p>In the file at ~\/.ipfs\/config change the following:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">$ nano ~\/.ipfs\/config \n<\/pre>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">&quot;API&quot;: &quot;\/ip4\/127.0.0.1\/tcp\/5001&quot;,\n&quot;Gateway&quot;: &quot;\/ip4\/127.0.0.1\/tcp\/8080&quot;\n<\/pre>\n<p>to&#8230;<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\"> \n&quot;API&quot;: &quot;\/ip4\/0.0.0.0\/tcp\/5001&quot;,\n&quot;Gateway&quot;: &quot;\/ip4\/0.0.0.0\/tcp\/8080&quot;\n<\/pre>\n<p>You can also run the commands below from the cli:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">$ ipfs config --json API.HTTPHeaders.Access-Control-Allow-Origin &#039;&#x5B;&quot;http:\/\/your_domain_name-or_ip_address.com:5001&quot;, &quot;http:\/\/localhost:3000&quot;, &quot;http:\/\/127.0.0.1:5001&quot;, &quot;https:\/\/webui.ipfs.io&quot;]&#039;\n$ ipfs config --json API.HTTPHeaders.Access-Control-Allow-Methods &#039;&#x5B;&quot;PUT&quot;, &quot;GET&quot;, &quot;POST&quot;]&#039;\n$ ipfs config Addresses.API \/ip4\/0.0.0.0\/tcp\/5001\n$ ipfs config Addresses.Gateway \/ip4\/0.0.0.0\/tcp\/8080\n<\/pre>\n<p>Restart IPFS after the changes<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">$ sudo systemctl restart ipfs\n<\/pre>\n<p>Load the URL to your site. In this case, I have an AWS instance but you can use the IP of your server or your domain name.<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">http:\/\/ip_address:8080\/ipfs\/QmQPeNsJPyVWPFDVHb77w8G42Fvo15z4bG2X8D2GhfbSXc \n<\/pre>\n<p><a href=\"https:\/\/qbytes.cloud\/wp-content\/uploads\/2021\/06\/ipfs2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-5791\" src=\"https:\/\/qbytes.cloud\/wp-content\/uploads\/2021\/06\/ipfs2-1024x309.png\" alt=\"\" width=\"640\" height=\"193\" srcset=\"https:\/\/www.qbytes.cloud\/wp-content\/uploads\/2021\/06\/ipfs2-1024x309.png 1024w, https:\/\/www.qbytes.cloud\/wp-content\/uploads\/2021\/06\/ipfs2-300x91.png 300w, https:\/\/www.qbytes.cloud\/wp-content\/uploads\/2021\/06\/ipfs2-768x232.png 768w, https:\/\/www.qbytes.cloud\/wp-content\/uploads\/2021\/06\/ipfs2-1536x463.png 1536w, https:\/\/www.qbytes.cloud\/wp-content\/uploads\/2021\/06\/ipfs2.png 1909w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/a><\/p>\n<p>Webui<\/p>\n<p>The webui is located at the following URL<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">http:\/\/ip_address:5001\/webui\nhttp:\/\/domain-name.com:5001\/webui\n<\/pre>\n<p><a href=\"https:\/\/qbytes.cloud\/wp-content\/uploads\/2021\/06\/webui.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-5945\" src=\"https:\/\/qbytes.cloud\/wp-content\/uploads\/2021\/06\/webui-1024x475.png\" alt=\"\" width=\"900\" height=\"417\" srcset=\"https:\/\/www.qbytes.cloud\/wp-content\/uploads\/2021\/06\/webui-1024x475.png 1024w, https:\/\/www.qbytes.cloud\/wp-content\/uploads\/2021\/06\/webui-300x139.png 300w, https:\/\/www.qbytes.cloud\/wp-content\/uploads\/2021\/06\/webui-768x356.png 768w, https:\/\/www.qbytes.cloud\/wp-content\/uploads\/2021\/06\/webui-1536x713.png 1536w, https:\/\/www.qbytes.cloud\/wp-content\/uploads\/2021\/06\/webui.png 1896w\" sizes=\"auto, (max-width: 900px) 100vw, 900px\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Installing IPFS through the command-line is handy if you plan on building applications and services on top of an IPFS node. This method is also useful if you&#8217;re setting up a node without a user interface, usually the case with remote servers or virtual machines. Using IPFS through the command-line allows you to do everything &#8230; <a title=\"Install IPFS on Debian 10 Buster\" class=\"read-more\" href=\"https:\/\/www.qbytes.cloud\/index.php\/2021\/06\/01\/install-ipfs-on-debian\/\" aria-label=\"Read more about Install IPFS on Debian 10 Buster\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[51],"tags":[],"class_list":["post-5758","post","type-post","status-publish","format-standard","hentry","category-ipfs"],"_links":{"self":[{"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/posts\/5758","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/comments?post=5758"}],"version-history":[{"count":0,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/posts\/5758\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/media?parent=5758"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/categories?post=5758"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/tags?post=5758"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}