Skip to content

Commit 09e4586

Browse files
authored
Merge pull request #4386 from ovh/jf-trans-exsi-security
EN files for securing an ESXI server
2 parents e58d9df + e50a374 commit 09e4586

File tree

8 files changed

+2115
-1
lines changed

8 files changed

+2115
-1
lines changed
Lines changed: 302 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,302 @@
1+
---
2+
title: 'Manage and secure your ESXi dedicated server from the outset'
3+
slug: esxi-hardening
4+
excerpt: 'Discover the various ways you can effectively secure your ESXi dedicated server'
5+
section: 'Security'
6+
order: 5
7+
updated: 2023-03-07
8+
---
9+
10+
**Last updated 7th March 2023**
11+
12+
## Objective
13+
14+
The purpose of this guide is to help you optimise security for your ESXi system.
15+
16+
In particular, this guide explains how to:
17+
18+
- Restrict access to your ESXi server to a specific IP address or network range.
19+
- Disable services that increase your server's attack surface.
20+
21+
We will do this using the on-board features offered by VMware, as well as those offered by OVHcloud.
22+
23+
> [!warning]
24+
>
25+
> Recently, ESXi systems fell victim to a security flaw that malicious groups exploited very quickly across public networks.
26+
>
27+
> You can find more information on this attack in [an additional FAQ](https://docs.ovh.com/asia/en/dedicated/esxi-faq/).
28+
>
29+
30+
### Security best practices reminder
31+
32+
- Update your ESXi systems regularly.
33+
- Restrict access to trusted IP addresses only.
34+
- Disable unused ports and services.
35+
- Ensure access to your servers or network equipment is limited, controlled and protected with strong passwords.
36+
- Back up your critical data to protected, isolated external disks and backup servers.
37+
38+
**Optional**:
39+
40+
- Set up the necessary logging solutions to monitor events on your critical servers and network equipment.
41+
- Set up security packs for malicious action detection, intrusion detection (IPS/NIDS) and network traffic bandwidth control.
42+
43+
## Requirements
44+
45+
- Access to the [OVHcloud Control Panel](https://ca.ovh.com/auth/?action=gotomanager&from=https://www.ovh.com/asia/&ovhSubsidiary=asia){.external}
46+
- A dedicated server with the ESXi solution deployed
47+
- An offer compatible with our [Network Firewall](https://docs.ovh.com/asia/en/dedicated/firewall-network/) feature, if you would like to use it for filtering
48+
49+
## Instructions
50+
51+
### Native intrusion protection
52+
53+
Reminder of its definition and operating principle:
54+
55+
> [!primary]
56+
>
57+
> The ESXi system includes a security mechanism linked to the administrator account.
58+
> This is because, in the event of several incorrect access attempts, the administrator account is temporarily locked.
59+
> This mechanism helps protect your system from malicious connection attempts.
60+
61+
> [!warning]
62+
>
63+
> If this system triggers and you want to log into your ESXi immediately, you will need to manually unlock the administrator account.
64+
>
65+
> To do this, you will need to [reboot](https://docs.ovh.com/asia/en/dedicated/getting-started-dedicated-server/#restarting-your-dedicated-server_1) your ESXi server via the OVHcloud Control Panel.
66+
>
67+
68+
You can view the access log history in the following files via SSH:
69+
70+
- `/var/run/log/vobd.log` contains the logs that can be used for monitoring and troubleshooting:
71+
72+
```
73+
2023-02-13T16:22:22.897Z: [UserLevelCorrelator] 410535559us: [vob.user.account.locked] Remote access for ESXi local user account 'root' has been locked for 900 seconds after 6 failed login attempts.
74+
2023-02-13T16:22:22.897Z: [GenericCorrelator] 410535559us: [vob.user.account.locked] Remote access for ESXi local user account 'root' has been locked for 900 seconds after 6 failed login attempts.
75+
2023-02-13T16:22:22.897Z: [UserLevelCorrelator] 410535867us: [esx.audit.account.locked] Remote access for ESXi local user account 'root' has been locked for 900 seconds after 6 failed login attempts.
76+
```
77+
78+
- `/var/run/log/hostd.log` contains ESXi host logs (tasks, access to the web interface, etc.):
79+
80+
```
81+
2023-02-21T08:44:19.711Z error hostd[2101004] [Originator@6876 sub=Default opID=esxui-d48c-26a4] [module:pam_lsass]pam_do_authenticate: error [login:root][error code:2]
82+
2023-02-21T08:44:19.711Z error hostd[2101004] [Originator@6876 sub=Default opID=esxui-d48c-26a4] [module:pam_lsass]pam_sm_authenticate: failed [error code:2]
83+
2023-02-21T08:44:19.712Z warning hostd[2101004] [Originator@6876 sub=Default opID=esxui-d48c-26a4] Rejected password for user root from xxx.xxx.xxx.xxx
84+
2023-02-21T08:44:19.712Z info hostd[2101004] [Originator@6876 sub=Vimsvc.ha-eventmgr opID=esxui-d48c-26a4] Event 175 : Cannot login [email protected]
85+
```
86+
87+
All this information is also available through the web administration interface. Click the `Host`{.action} menu and navigate to the `Monitor`{.action} section, and then click `Logs`{.action}.
88+
89+
![interface](images/gui_logs_.png){.thumbnail}
90+
91+
### The Network Firewall solution
92+
93+
> [!primary]
94+
>
95+
> As a reminder, the Network Firewall is not taken into account within the OVHcloud network. As a result, the configured rules do not affect connections from this internal network.
96+
>
97+
98+
You can enable and use our [Network Firewall](https://docs.ovh.com/asia/en/dedicated/firewall-network/) filtering solution.
99+
This solution will allow you to easily manage legitimate access, in addition to the access you have set up through your ESXi system.
100+
101+
It will also prevent you from unexpectedly locking your administrator account in the event of an attack.
102+
103+
It is recommended that you filter legitimate access in this way:
104+
105+
- Rule 1 (Priority 0) allows trusted external networks to access your ESXi system.
106+
- Rule 2 (Priority 1) blocks everything else.
107+
108+
![Network_Firewall](images/firewall_network_.png){.thumbnail}
109+
110+
### Filtering in ESXi
111+
112+
> [!primary]
113+
>
114+
> You can also filter access to your ESXi system with the built-in firewall.
115+
> You can also disable unnecessary services, depending on your usage.
116+
>
117+
118+
> [!warning]
119+
>
120+
> We strongly advise disabling **SSH** and **SLP** services.
121+
> If you still use the SSH service, restrict its use and access as much as possible.
122+
> This also applies to **shell** access.
123+
> Prioritise only what is strictly necessary for each of your needs.
124+
125+
#### Manipulation via the graphical interface
126+
127+
**Services**
128+
129+
Click the `Host`{.action} menu and navigate to the `Manage`{.action} section, then click `Services`{.action}.
130+
131+
In the list, find the `TSM-SSH` service and right-click on the associated line.
132+
133+
Stop the service by clicking `Stop`{.action}:
134+
135+
![services_ssh](images/stop_service.png){.thumbnail}
136+
137+
Select the `Policy`, then edit it as shown in the example.
138+
139+
Choose the `Start and stop manually`{.action} option to prevent the service from being active when the server starts.
140+
141+
![services_ssh](images/ssh_disabled_.png){.thumbnail}
142+
143+
Apply the same settings for the `slpd` service:
144+
145+
![services_slp](images/slpd_.png){.thumbnail}
146+
147+
**Firewall rules**
148+
149+
Click the `Networking`{.action} menu, then `Firewall rules`{.action}, and choose `Edit settings`{.action} for each service you want to protect:
150+
151+
![rules](images/firewall_web_.png){.thumbnail}
152+
153+
Edit the rule to add only IP addresses or networks that need access to your ESXi system.
154+
155+
Example that only allows connections from IP 192.168.1.10:
156+
157+
![custom](images/custom_fw_rule.png){.thumbnail}
158+
159+
#### Shell manipulation
160+
161+
**Services**
162+
163+
Disable unnecessary services:
164+
165+
- SLP Service
166+
167+
```bash
168+
/etc/init.d/slpd stop
169+
esxcli network firewall ruleset set -r CIMSLP -e 0
170+
chkconfig slpd off
171+
```
172+
173+
- SSH Service
174+
175+
```bash
176+
/etc/init.d/SSH stop
177+
esxcli network firewall ruleset set -r sshServer -e 0
178+
chkconfig SSH off
179+
```
180+
181+
Check all active services at startup:
182+
183+
```bash
184+
chkconfig --list | grep on
185+
```
186+
<br/>
187+
<br/>
188+
189+
**Firewall rules**
190+
191+
View existing firewall rules:
192+
193+
```bash
194+
esxcli network firewall ruleset list
195+
esxcli system account list
196+
```
197+
198+
> Explanations for changing/adapting access rules:
199+
>
200+
> - The `vSphereClient` service: This service corresponds to the web administration interface on port 443 (HTTPS).
201+
> - The `sshServer` service: This service corresponds to SSH access on port 22.
202+
203+
Example with the vSphereClient service:
204+
205+
```bash
206+
esxcli network firewall ruleset list --ruleset-id vSphereClient
207+
```
208+
209+
Ensure that the firewall rule is active:
210+
211+
```bash
212+
esxcli network firewall ruleset set --ruleset-id vSphereClient --enabled true
213+
```
214+
215+
Display the list of authorised IPs for this rule:
216+
217+
```bash
218+
esxcli network firewall ruleset allowedip list --ruleset-id vSphereClient
219+
```
220+
221+
Result:
222+
223+
```
224+
Ruleset Allowed IP Addresses
225+
------------- --------------------
226+
vSphereClient All
227+
```
228+
229+
Change the status of the tag by disabling it:
230+
231+
```bash
232+
esxcli network firewall ruleset set --ruleset-id vSphereClient --allowed-all false
233+
```
234+
235+
Authorise only the legitimate IP address 192.168.1.10:
236+
237+
```bash
238+
esxcli network firewall ruleset allowedip add --ruleset-id vSphereClient --ip-address 192.168.1.10
239+
```
240+
241+
Check the access list for the address:
242+
243+
```bash
244+
esxcli network firewall ruleset allowedip list --ruleset-id vSphereClient
245+
```
246+
247+
Result:
248+
249+
```
250+
Ruleset Allowed IP Addresses
251+
------------- --------------------
252+
vSphereClient 192.168.1.10
253+
```
254+
<br/>
255+
<br/>
256+
257+
If you still want to use the SSH service, we will explain here how to set up SSH key access.
258+
259+
Generate the keys on the machine that needs to connect to the ESXi server. The 521-bit **ECDSA** algorithm should be used for maximum security:
260+
261+
> [!warning]
262+
> Authentication works with a key pair: one public and one private.
263+
> Do not share your **private** key, it must remain on the machine where it was generated.
264+
265+
Run the following command:
266+
267+
```bash
268+
ssh-keygen -t ecdsa -b 521 -C "key-ecdsa-esxi-host" -f /path-to-my-key/key-ecdsa
269+
```
270+
271+
```
272+
Generating public/private ecdsa key pair.
273+
Enter file in which to save the key (/path-to-my-key/key-ecdsa_rsa):
274+
```
275+
276+
Enter a strong password:
277+
278+
```
279+
Enter passphrase (empty for no passphrase):
280+
Enter same passphrase again:
281+
```
282+
283+
Only the public key (key-ecdsa.pub) must be sent or stored on the machines you want to connect to.
284+
285+
```
286+
Your identification has been saved in /path-to-my-key/key-ecdsa.
287+
Your public key has been saved in /path-to-my-key/key-ecdsa.pub.
288+
The key fingerprint is:
289+
SHA256:******************************************* key-ecdsa-esxi-host
290+
```
291+
292+
Transfer the public key to your ESXi host so that it can be declared as trusted:
293+
294+
```bash
295+
cat /path-to-my-key/key-ecdsa.pub | ssh root@esxi-host-ip 'cat >> /etc/ssh/keys-root/authorized_keys'
296+
```
297+
298+
## Go further
299+
300+
You can find even more details on security best practices in [this VMware suggested guide](https://core.vmware.com/security-configuration-guide).
301+
302+
Join our community of users on <https://community.ovh.com/en/>.

0 commit comments

Comments
 (0)