Skip to content

Commit ac7ba1e

Browse files
author
Marvin Ottersberg
committed
docs: finished setting up debian server
1 parent c331f1d commit ac7ba1e

File tree

1 file changed

+156
-3
lines changed

1 file changed

+156
-3
lines changed

README.md

Lines changed: 156 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,15 @@ This is the documentation for setting up a Tezos Baker/Validator node with a ser
88
- [2. Hardening the server](#2-hardening-the-server)
99
- [2.1 Login to server](#21-login-to-server)
1010
- [2.2 Create new user with sudo privileges](#22-create-new-user-with-sudo-privileges)
11-
11+
- [2.3 Disable SSH password Authentication and Use SSH Keys only](#23-disable-ssh-password-authentication-and-use-ssh-keys-only)
12+
- [2.4 Update your system](#24-update-your-system)
13+
- [2.5 Disable root account](#25-disable-root-account)
14+
- [2.6 Secure Shared Memory](#26-secure-shared-memory)
15+
- [2.7 Install Fail2ban](#27-install-fail2ban)
16+
- [whitelisted IP addresses](#whitelisted-ip-addresses)
17+
- [ignoreip = \<list of whitelisted IP address, your local daily laptop/pc\>](#ignoreip--list-of-whitelisted-ip-address-your-local-daily-laptoppc)
18+
- [2.8 Configure your Firewall](#28-configure-your-firewall)
19+
- [2.9 Verify Listening Ports](#29-verify-listening-ports)
1220

1321
# 1. Prerequisites
1422

@@ -45,7 +53,7 @@ The node is intended for baking with no need to store content of every previous
4553

4654
1. Got to [ovh.com](https://www.ovh.com)
4755

48-
- Select *Virtual Private Server*.
56+
- Select _Virtual Private Server_.
4957

5058
![Step 1](./img/1-choose_vps.png)
5159

@@ -82,7 +90,7 @@ The node is intended for baking with no need to store content of every previous
8290

8391
## 2.1 Login to server
8492

85-
ssh debian@51.75.73.221
93+
ssh debian@server.public.ip.address
8694

8795
## 2.2 Create new user with sudo privileges
8896

@@ -92,6 +100,151 @@ This creates a new user named tezos, sets the password and adds tezos user to su
92100
sudo passwd tezos
93101
sudo usermod -aG sudo tezos
94102

103+
104+
## 2.3 Disable SSH password Authentication and Use SSH Keys only
105+
106+
The basic rules of hardening SSH are:
107+
108+
- No password for SSH access (use private key)
109+
- Don't allow root to SSH (the appropriate users should SSH in, then su or sudo)
110+
- Use sudo for users so commands are logged
111+
- Log unauthorized login attempts (and consider software to block/ban users who try to access your server too many times, like fail2ban)
112+
- Lock down SSH to only the ip range your require (if you feel like it)
113+
95114
Create a new ssh key locally
96115

97116
ssh-keygen -t ed25519 -f ~/.ssh/my_custom_key_name -C "comment or label for this key"
117+
118+
Transfer the public key to your remote node. Update keyname.pub appropriately.
119+
120+
ssh-copy-id -i $HOME/.ssh/keyname.pub ethereum@server.public.ip.address
121+
122+
Login with your new ethereum user
123+
124+
ssh tezos@server.public.ip.address
125+
126+
Disable root login and password based login. Edit the /etc/ssh/sshd_config file
127+
128+
sudo nano /etc/ssh/sshd_config
129+
130+
Validate the syntax of your new SSH configuration.
131+
132+
sudo sshd -t
133+
134+
If no errors with the syntax validation, restart the SSH process
135+
136+
sudo systemctl restart sshd
137+
138+
## 2.4 Update your system
139+
It's critically important to keep your system up-to-date with the latest patches to prevent intruders from accessing your system.
140+
141+
sudo apt-get update -y && sudo apt dist-upgrade -y
142+
sudo apt-get autoremove
143+
sudo apt-get autoclean
144+
145+
Enable automatic updates so you don't have to manually install them.
146+
147+
sudo apt-get install unattended-upgrades
148+
sudo dpkg-reconfigure -plow unattended-upgrades
149+
150+
## 2.5 Disable root account
151+
System admins should not frequently log in as root in order to maintain server security. Instead, you can use sudo execute that require low-level privileges.
152+
153+
To disable the root account, simply use the -l option.
154+
155+
sudo passwd -l root
156+
157+
If for some valid reason you need to re-enable the account, simply use the -u option.
158+
159+
sudo passwd -u root
160+
161+
## 2.6 Secure Shared Memory
162+
One of the first things you should do is secure the shared memory used on the system. If you're unaware, shared memory can be used in an attack against a running service. Because of this, secure that portion of system memory.
163+
164+
Edit /etc/fstab
165+
166+
sudo nano /etc/fstab
167+
168+
Insert the following line to the bottom of the file and save/close. This sets shared memory into read-only mode.
169+
170+
tmpfs /run/shm tmpfs ro,noexec,nosuid 0 0
171+
172+
Reboot the node in order for changes to take effect.
173+
174+
sudo reboot
175+
176+
Check with this command. (ro, nosuid,noexec = read-only, no setuid, no execute)
177+
178+
mount | grep /run/shm
179+
180+
## 2.7 Install Fail2ban
181+
Fail2ban is an intrusion-prevention system that monitors log files and searches for particular patterns that correspond to a failed login attempt. If a certain number of failed logins are detected from a specific IP address (within a specified amount of time), fail2ban blocks access from that IP address.
182+
183+
sudo apt-get install fail2ban -y
184+
185+
Edit a config file that monitors SSH logins.
186+
187+
sudo nano /etc/fail2ban/jail.local
188+
189+
Add the following lines to the bottom of the file.
190+
Whitelisting IP address tip: The ignoreip parameter accepts IP addresses, IP ranges or DNS hosts that you can specify to be allowed to connect. This is where you want to specify your local machine, local IP range or local domain, separated by spaces.
191+
192+
193+
[sshd]
194+
enabled = true
195+
port = 22
196+
filter = sshd
197+
logpath = /var/log/auth.log
198+
maxretry = 3
199+
# whitelisted IP addresses
200+
# ignoreip = <list of whitelisted IP address, your local daily laptop/pc>
201+
202+
Save/close file.
203+
Restart fail2ban for settings to take effect.
204+
205+
sudo systemctl restart fail2ban
206+
207+
## 2.8 Configure your Firewall
208+
The standard UFW firewall can be used to control network access to your node. With any new installation, ufw is disabled by default. Enable it with the following settings.
209+
210+
By default, deny all incoming and outgoing traffic
211+
212+
sudo ufw default deny incoming
213+
sudo ufw default allow outgoing
214+
215+
Allow ssh access
216+
217+
sudo ufw allow ssh
218+
219+
Allow p2p ports
220+
221+
sudo ufw allow 13000/tcp
222+
sudo ufw allow 12000/udp
223+
224+
Allow eth1 port
225+
226+
sudo ufw allow 30303/tcp
227+
sudo ufw allow 30303/udp
228+
229+
Allow tezos node P2P and RPC connections
230+
231+
sudo ufw allow 9732/tcp
232+
233+
Enable firewall
234+
235+
sudo ufw enable
236+
237+
Check status
238+
239+
sudo ufw status verbose
240+
241+
Might want to enable ufw logging
242+
243+
sudo ufw logging on
244+
245+
>Note It is dangerous to open 3000 / 9090 for Grafana or Prometheus on a VPS/cloud node.
246+
247+
## 2.9 Verify Listening Ports
248+
If you want to maintain a secure server, you should validate the listening network ports every once in a while. This will provide you essential information about your network.
249+
250+
sudo ss -tulpn or sudo netstat -tulpn

0 commit comments

Comments
 (0)