Advertisement
e01

I2P RELAY

e01
May 27th, 2018
405
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.15 KB | None | 0 0
  1. ======================================================================================================================================
  2. e01 @AccessPwned 2018
  3. ======================================================================================================================================
  4. SETUP AN I2P RELAY
  5.  
  6. I2P is a great network, but like any other decentralized system it relies on a diverse set of actors to operate resiliently. For example, if it ran on ten servers, six of which were controlled by [insert government agency here], then it wouldn't be very secure. Thus, one of the easiest, best ways that you can help support I2P is to run your own high-bandwidth node on a VPS (Virtual Private Server). While running a node at home definitely helps, slow residential internet speeds and unstable desktop computers put a cap on just how helpful the node can be to the network. Using a VPS with a gigabit connection on the other hand adds significantly to the speed, capacity, and robustness of the network.
  7.  
  8. In fact, not only does running I2P on a VPS benefit the network, it can also function as a reliable I2P portal that you can connect to from anywhere. For example, if you boot up your laptop in a coffee shop and want to get onto I2P without waiting ten minutes to build enough tunnels, you can instead just connect your laptop to your VPS and get online instantly*.
  9.  
  10. This tutorial will teach you how to set up a fairly secure server on Digital Ocean that functions as a high-bandwidth router on the I2P network. Of course, you can chose whatever hosting provider you like, but Digital Ocean is my favorite, and signing up through This referral link will give you a $10 credit for free, enough to run the server for two months. It also gives me a small kickback, which helps keep ads off the site (once you spend $25, I get $25 myself).
  11.  
  12. *There are some cons to this as well, primarily that the hosting provider could watch what you're doing. But for low risk activities, like chatting on IRC, it shouldn't be an issue.
  13. Server Setup
  14.  
  15. If you've read my Owncloud setup guide, most of the steps here will be quite similar, though slightly different this time around. Also, if you're using another hosting provider you should probably just skip this part as it's fairly specific to Digital Ocean.
  16.  
  17. The first step of course is to sign up for Digital Ocean if you don't already have an account, and then to create a new droplet. I called my droplet 'i2prouter', and selected the $5 per month option, which will give you 1TB of bandwidth out to the network. I also selected the London data-center. I've set up around ten I2P routers recently and found London to be one of the fastest. Next, select which operating system you want to run (this guide is based on Debian 7). Lastly, we're going to upload our own SSH key, rather than use a password. This makes the server significantly more secure and faster to log into. If you're on Windows, then give this guide a read. Linux users who don't already have an SSH key can simply type into the terminal:
  18.  
  19.  
  20. ssh-keygen -t rsa
  21.  
  22. Issuing this command will ask a few questions, which you can simply mash enter through, before generating a SSH keypair. We'll need to copy and paste the public key into the droplet creation page, so if you saved your key in the default location simply type:
  23.  
  24.  
  25. cat ~/.ssh/id_rsa.pub
  26.  
  27. Copy and paste the contents of this into the 'Add SSH Key' field on Digital Ocean, and then create the droplet. Once the droplet has been created, write down its IP address and go back to your terminal to SSH into it:
  28.  
  29.  
  30. ssh root@[Enter IP Address Here]
  31.  
  32. Now that we're connected to the server we're going to change a few things so that it doesn't become the property of Russians in 3 hours. First, we'll make a new user called i2p (you can name it whatever you want, but throughout this tutorial I'll reference it as i2p):
  33.  
  34.  
  35. adduser i2p
  36.  
  37. Give it a fairly strong password, then skip through the name and number fields. We now need to give this user some higher level privileges through sudo:
  38.  
  39.  
  40. visudo
  41.  
  42. Add a line so that it looks like this, of course replacing the 'i2p' with whatever username you chose:
  43.  
  44.  
  45. root ALL=(ALL:ALL) ALL
  46.  
  47. i2p ALL=(ALL:ALL) ALL
  48.  
  49. What we've just done is given the user i2p the ability to execute commands as if it were the root user by simply typing sudo before the command. Using sudo instead of root has a number of benefits, especially when it comes to auditing and permission limiting. We're allowing it to execute any commands right now, but we'll lock it down later so that it is a bit more secure. The last thing we'll do before logging out and back in as the new user we've created is give root a password:
  50.  
  51.  
  52. passwd root
  53.  
  54. Give root a very strong password, then issue the following commands, which will log out, copy your SSH key to the new user you just created, and then log back in as that user:
  55.  
  56.  
  57. exit
  58.  
  59. ssh-copy-id i2p@[Enter IP Address Here]
  60.  
  61. ssh i2p@[Enter IP Address Here]
  62.  
  63. Next, we'll upgrade the system and install some new software:
  64.  
  65.  
  66. sudo apt-get update && apt-get upgrade -y
  67.  
  68. sudo apt-get install ufw fail2ban -y
  69.  
  70. Now we need to edit the SSH settings:
  71.  
  72.  
  73. sudo nano /etc/ssh/sshd_config
  74.  
  75. Within this text file we're going to change the SSH port to something random like 3451, change PermitRootLogin to no, and change PasswordAuthentication to no:
  76.  
  77.  
  78. Port [Enter Random Port Here]
  79.  
  80. PermitRootLogin no
  81.  
  82. PasswordAuthentication no
  83.  
  84. Close and save this by hitting Control+X, then Y, then enter, making sure to take note of the new port number you just gave. Now we need to reload the SSH configuration that we just changed:
  85.  
  86.  
  87. sudo service ssh reload
  88.  
  89. Because we just changed the port for SSH, the next time you log in you'll need to add "-p [port number here]" to the end of the ssh command.
  90.  
  91. The two programs we installed back when we upgraded the system were ufw and fail2ban, and now we need to set them up. UFW is a program which makes setting up firewalls extremely easy. All you need to do is execute these commands, making sure that you enter the correct ssh port, otherwise you'll be locked out!
  92.  
  93.  
  94. sudo ufw allow [Enter SSH Port Here]
  95.  
  96. sudo ufw default deny
  97.  
  98. sudo ufw enable
  99.  
  100. Now that the firewall is set up, we're going to set up fail2ban so that if anyone does find the right SSH port they'll get locked out after making a few failed attempts, so pump this into your terminal:
  101.  
  102.  
  103. sudo cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local
  104.  
  105. sudo service fail2ban restart
  106.  
  107. Installing I2P
  108.  
  109. If you've gotten this far, you've got a 'secure-enough' platform that you can now install I2P on. The easiest way to do this is to add the I2P repository, by editing your sources file and copying and pasting a couple of lines into it:
  110.  
  111.  
  112. sudo nano /etc/apt/sources.list
  113.  
  114. Now add these lines to the bottom:
  115.  
  116.  
  117. deb http://deb.i2p2.no/ stable main
  118.  
  119. deb-src http://deb.i2p2.no/ stable main
  120.  
  121. Exit out of that, then download the keyring, update your sources, and install I2P with these commands:
  122.  
  123.  
  124. wget https://geti2p.net/_static/i2p-debian-repo.key.asc
  125.  
  126. sudo apt-key add i2p-debian-repo.key.asc
  127.  
  128. sudo apt-get update
  129.  
  130. sudo apt-get install i2p i2p-keyring -y
  131.  
  132. sudo dpkg-reconfigure i2p
  133.  
  134. You'll get a question asking if you want to start I2P at boot, as well as how much RAM you want to give. I set it to start at boot, and gave it 400Mb.
  135.  
  136. If you've gotten to this point, you now have I2P installed! But you've still got a little bit more to go!
  137. Configuring I2P
  138.  
  139. There's still a few things that we need to tweak to get I2P fully up and running. The first thing we're going to do is type 'exit' into the terminal, before reconnecting, but this time slightly differently:
  140.  
  141.  
  142. ssh -L 7657:127.0.0.1:7657 i2p@[Enter IP Address Here] -p [Enter SSH Port Here]
  143.  
  144. What this command has just done, other than log you into the server, is forward the 7657 port on your computer to 7657 on the server. This means that if you pump the following link into your browser, you'll be connected to the I2P web interface on the server:
  145.  
  146.  
  147. http://127.0.0.1:7657/config
  148.  
  149. The first thing we'll change here is the bandwidth, setting it to 400KBps, sharing 100% of it. This equates to just over your 1TB limit on the $5 droplet (if you chose a larger droplet size, you may want to raise this).
  150.  
  151. Now we'll go to the Network tab and write down the default port that's been set. We're going to need to add a firewall for this a bit later.
  152.  
  153. Navigate to the Tunnels tab, and set the exploratory tunnel length, quantity, and backup quantity all to their maximum. This will integrate your router more quickly into the network. Setting up tunnels is quite expensive on the CPU, so you might want to lower this later once your router is fairly integrated and pushing a high bandwidth, but I find it helps integrate the router quickly on initial setup. It will be a good idea to write down the default settings before changing them so that you can revert later.
  154.  
  155. Last but not least is to add that firewall rule to make I2P accessible. Go back to your terminal and add a UFW rule for the port you noted previously:
  156.  
  157.  
  158. sudo ufw allow [Enter I2P Port Here]
  159.  
  160. And that's pretty much it. I2P should be up and running, and after a few minutes the console page should read 'Network: OK' on the left hand side.
  161. Loose Ends
  162.  
  163. There's still one loose end we need to tie, and that's sudo permissions. Right now your i2p user is allowed to do anything, and we want to tighten this up a bit.
  164.  
  165.  
  166. sudo visudo
  167.  
  168. Now you want to change where it says 'i2p ALL=(ALL:ALL) ALL' to:
  169.  
  170.  
  171. i2p ALL=(ALL:ALL) /usr/sbin/service i2p *, /usr/bin/apt-get
  172.  
  173. What we've just done is allow the i2p user to install or update software, and start/stop/restart the i2p service. Other than that they're all locked down. If you ever want to change this you'll have to log in as root and update the permissions again. But for now, let's get out of here:
  174.  
  175.  
  176. exit
  177.  
  178. You're Done.
  179.  
  180. That's pretty much it. It will take a few days for the bandwidth to start creeping up, but you've now got a high bandwidth router contributing to the I2P network. Remember to log into it every once in a while to update the system. Other than that though, it should be fairly set-and-forget.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement