Skip to content

Commit f241ca7

Browse files
authored
Update to avoid putting HA user in sudoers
None of the steps require that HA is added to sudoers or given a password. Rewriting those steps to remove that, to improve overall security.
1 parent 98106b5 commit f241ca7

File tree

1 file changed

+4
-49
lines changed

1 file changed

+4
-49
lines changed

source/_docs/ecosystem/certificates/lets_encrypt.markdown

Lines changed: 4 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -240,21 +240,7 @@ In cases where your ISP blocks port 80 you will need to change the port forward
240240

241241
Now SSH in to the device your Home Assistant is running on.
242242

243-
<p class='note'>
244-
If you're running the 'standard' setup on a Raspberry Pi the chances are you just logged in as the 'pi' user. If not, you may have logged in as the Home Assistant user. There are commands below that require the Home Assistant user to be on the `sudoers` list. If you are not using the 'standard' pi setup it is presumed you will know how to get your Home Assistant user on the `sudoers` list before continuing. If you are running the 'standard' pi setup, from your 'pi' user issue the following command (where `hass` is the Home Assistant user):
245-
246-
```
247-
$ sudo adduser hass sudo
248-
```
249-
</p>
250-
251-
If you did not already log in as the user that currently runs Home Assistant, change to that user (usually `hass` or `homeassistant` - you may have used a command similar to this in the past):
252-
253-
```bash
254-
$ sudo su -s /bin/bash hass
255-
```
256-
257-
Make sure you are in the home directory for the HA user:
243+
Make sure you are in the home directory for your user:
258244

259245
```bash
260246
$ cd
@@ -288,11 +274,11 @@ This should show a folder named exactly after your DuckDNS URL.
288274
Our Home Assistant user needs access to files within the letsencrypt folder, so issue the following commands to change the permissions.
289275

290276
```bash
291-
$ sudo chmod 755 /etc/letsencrypt/live/
292-
$ sudo chmod 755 /etc/letsencrypt/archive/
277+
$ sudo chmod a+x /etc/letsencrypt/live/
278+
$ sudo chmod a+x /etc/letsencrypt/archive/
293279
```
294280

295-
Did all of that go without a hitch? Wahoo! Your Let's Encrypt certificate is now ready to be used with Home Assistant. Move to step 5 to put it all together
281+
Did all of that go without a hitch? Wahoo! Your Let's Encrypt certificate is now ready to be used with Home Assistant. Move to step 5 to put it all together.
296282

297283
### {% linkable_title 5 - Check the incoming connection %}
298284

@@ -442,12 +428,6 @@ Your certificate can be renewed as a 'cron job' - cron jobs are background tasks
442428
To set a cron job to run the script at regular intervals:
443429

444430
* SSH in to your device running Home Assistant.
445-
* Change to your Home Assistant user (command similar to):
446-
447-
```bash
448-
$ sudo su -s /bin/bash hass
449-
```
450-
451431
* Open the crontab:
452432

453433
```bash
@@ -474,37 +454,12 @@ $ crontab -e
474454

475455

476456
#### Option 2:
477-
You can set an automation in Home Assistant to run the certbot renewal script.
478-
479-
Add the following sections to your configuration.yaml if you are a TWO-RULE person
480-
481-
```yaml
482-
shell_command:
483-
renew_ssl: ~/certbot/certbot-auto renew --quiet --no-self-upgrade --standalone --preferred-challenges http-01
484-
485-
automation:
486-
- alias: 'Auto Renew SSL Cert'
487-
trigger:
488-
platform: numeric_state
489-
entity_id: sensor.ssl_cert_expiry
490-
below: 29
491-
action:
492-
service: shell_command.renew_ssl
493-
```
494-
If you are a ONE-RULE person, replace the `certbot-auto` command above with `~/certbot/certbot-auto renew --quiet --no-self-upgrade --standalone --preferred-challenges tls-sni-01 --tls-sni-01-port 8123 --pre-hook "sudo systemctl stop home-assistant@homeassistant.service" --post-hook "sudo systemctl start home-assistant@homeassistant.service"`
495-
496457
#### Option 3:
497458
You can manually update the certificate when your certificate is less than 30 days to expiry.
498459

499460
To manually update:
500461

501462
* SSH in to your device running Home Assistant.
502-
* Change to your Home Assistant user (command similar to):
503-
504-
```bash
505-
$ su - s /bin/bash hass
506-
```
507-
508463
* Change to your certbot folder
509464

510465
```bash

0 commit comments

Comments
 (0)