|
| 1 | +# Configuring a Tailscale VPN Server |
| 2 | + |
| 3 | +::: tip NOTE |
| 4 | +This is **optional.** |
| 5 | +You only need to consider this section if you run a node at home and would like to connect to it from outside of your home network. |
| 6 | +::: |
| 7 | + |
| 8 | +If you would like to log into your home network remotely, such as while on vacation or on a business trip, the most common route is to use a **Virtual Private Network** server. |
| 9 | +This will allow you to connect to your node via SSH **and** monitor your Graphana dashboard from anywhere in the world, all without exposing your SSH port to the internet. |
| 10 | + |
| 11 | +Many Rocket Pool node operators use [Tailscale]((https://tailscale.com/blog/how-tailscale-works/)) as their VPN server of choice for this. |
| 12 | +Tailscale is an open source P2P VPN tunnel and hosted endpoint discovery service. |
| 13 | +It takes care of authentication, publication, and the NAT traversal required to establish an end-to-end encrypted path between your machine and your node without sending any sensitive traffic to a centralized server. |
| 14 | +It is a very powerful tool. |
| 15 | + |
| 16 | +We will briefly cover a basic configuration of it, but feel free to [review their documentation](https://tailscale.com/kb/start/) for more details. |
| 17 | + |
| 18 | + |
| 19 | +## Setting Tailscale Up |
| 20 | + |
| 21 | +First, create a free [Tailscale account](https://tailscale.com/). |
| 22 | +Tailscale requires the use of an SSO identity provider such as Google, GitHub, Okta, Microsoft, etc. |
| 23 | +For details, visit [their SSO Page](https://tailscale.com/kb/1013/sso-providers/). |
| 24 | + |
| 25 | +It is recommended that you enable 2FA (Two Factor Authentication) on whichever identity provider you choose for added security. |
| 26 | + |
| 27 | +Next, follow [their onboarding guide](https://tailscale.com/kb/1017/install/) to install Tailscale on your **client** - the machine you want to connect to your network with. |
| 28 | +For example, this could be a laptop or your phone. |
| 29 | +**Note that it is *not* your Rocket Pool node!** |
| 30 | + |
| 31 | +Once completed you should see your computer as 'connected' on the [Tailscale dashboard](https://login.tailscale.com/admin/machines). |
| 32 | + |
| 33 | +<center> |
| 34 | + |
| 35 | + |
| 36 | + |
| 37 | +</center> |
| 38 | + |
| 39 | +Now, install Tailscale on your **Rocket Pool node**. |
| 40 | +You can find instructions for this on their website; for example, here are the [installation instructions for Ubuntu](https://tailscale.com/kb/1039/install-ubuntu-2004/). |
| 41 | + |
| 42 | +::: warning NOTE |
| 43 | +If you have UFW configured, you will also want to follow the [UFW Configuration Instructions](https://tailscale.com/kb/1077/secure-server-ubuntu-18-04/)). |
| 44 | +::: |
| 45 | + |
| 46 | +First, add Tailscale’s package signing key and repository **on your Rocket Pool node**: |
| 47 | + |
| 48 | +```shell |
| 49 | +curl -fsSL https://pkgs.tailscale.com/stable/ubuntu/focal.noarmor.gpg | sudo tee /usr/share/keyrings/tailscale-archive-keyring.gpg >/dev/null |
| 50 | +curl -fsSL https://pkgs.tailscale.com/stable/ubuntu/focal.tailscale-keyring.list | sudo tee /etc/apt/sources.list.d/tailscale.list |
| 51 | +``` |
| 52 | + |
| 53 | +Now, install Tailscale **on your Rocket Pool node**: |
| 54 | + |
| 55 | +```shell |
| 56 | +sudo apt-get update |
| 57 | +sudo apt-get install tailscale |
| 58 | +``` |
| 59 | + |
| 60 | +Finally, authenticate and connect your machine to your Tailscale network **on your Rocket Pool node**: |
| 61 | + |
| 62 | +```shell |
| 63 | +sudo tailscale up |
| 64 | +``` |
| 65 | + |
| 66 | +You’re connected! |
| 67 | +You can find your Tailscale IPv4 address by running: |
| 68 | + |
| 69 | +```shell |
| 70 | +tailscale ip -4 |
| 71 | +``` |
| 72 | + |
| 73 | +You should now see your node machine added to the on the [Tailscale dashboard](https://login.tailscale.com/admin/machines). |
| 74 | +You may also change the name of the **node machine** through the dashboard, e.g. to `rocketnode`. |
| 75 | + |
| 76 | + |
| 77 | + |
| 78 | +It is suggested to [disable key expiry](https://tailscale.com/kb/1028/key-expiry) for the node machine to prevent the need to periodically re-authenticate. |
| 79 | + |
| 80 | +::: tip Note |
| 81 | +If you would like to access your node using a memorable hostname such as rocketnode, you can do so by enabling MagicDNS in the Tailscale settings. |
| 82 | +::: |
| 83 | + |
| 84 | +You should now be able to `exit` the SSH session to your node on your client, and SSH into your node again through Tailscale using `ssh your.user@rocketnode`. |
| 85 | + |
| 86 | +::: warning NOTE |
| 87 | +If you modified the SSH port of the **node machine** in `/etc/ssh/sshd_config` when you first configured it, use `ssh your.user@rocketnode -p <your port>` instead. |
| 88 | + |
| 89 | +For example, if you assigned SSH to port 1234, you would do: |
| 90 | +``` |
| 91 | +ssh your.user@rocketnode -p 1234 |
| 92 | +``` |
| 93 | +::: |
| 94 | + |
| 95 | +You can now also visit `http://rocketnode:3100` in your web browser to access your Grafana dashboard from your **client**. |
| 96 | + |
| 97 | +If you have UFW configured, you can now add a rule to accept any incoming SSH connections over Tailscale. |
| 98 | + |
| 99 | +::: danger WARNING |
| 100 | +The following steps will modify your firewall rules. |
| 101 | +**You must have at least 2 SSH sessions open to your node machine before proceeding - one for modifying the configuration and testing it afterwards, and one that will stay logged in as a backup in case your changes break SSH so you can revert them! |
| 102 | +::: |
| 103 | + |
| 104 | +**Run these commands on the node machine.** |
| 105 | + |
| 106 | +Allow access to all incoming ssh connections over Talscale. |
| 107 | + |
| 108 | +```shell |
| 109 | +sudo ufw allow in on tailscale0 |
| 110 | +``` |
| 111 | + |
| 112 | +You may also remove access to the SSH port adding from the [enabling a firewall](securing-your-node.md#essential-enable-a-firewall) steps to competely lock down your node. |
| 113 | +Note that you **will not** be able to login from the local network as tailscale will become the only way to login. |
| 114 | +Only run the following command if you are okay with this. |
| 115 | + |
| 116 | +```shell |
| 117 | +sudo ufw delete "22/tcp" |
| 118 | +``` |
| 119 | + |
| 120 | +Once you’ve set up firewall rules to restrict all non-Tailscale connections, restart UFW and SSH: |
| 121 | + |
| 122 | +```shell |
| 123 | +sudo ufw reload |
| 124 | +sudo service ssh restart |
| 125 | +``` |
| 126 | + |
| 127 | +Now, confirm that everything is working as expected. |
| 128 | +`exit` from one of your current SSH sessions (**but remember to keep the second one open as a backup**). |
| 129 | + |
| 130 | +Next, connect to the **node machine** via SSH using the Tailscale IP address: |
| 131 | + |
| 132 | +```shell |
| 133 | +ssh your.user@rocketnode |
| 134 | +``` |
| 135 | + |
| 136 | +If it works, you did everything right and can now safely log into your home network while abroad! |
| 137 | + |
| 138 | +::: tip TIP |
| 139 | +If you've previously port forwarded your node's SSH port in your router, you can now remove it. |
| 140 | +::: |
0 commit comments