How to set up DuckDNS, SSL hassbian

So for the past three days I’ve been struggling to set up push notifications since the guides miss some pretty crucial steps. I finally got it working and hoping to save someone headache in the future, I’m going to write a quick guide. I’ll likely use this myself if I need to set it up again.

Assumption

  1. Up-to-Date Home Assistant
  2. Installed on a Raspberry Pi
  3. Used All-In-One Installer

DuckDNS

Home-assistant.io guide 946

Bruh-automation guide (with video) 574

  1. Log into your router and go to NAT/Gaming or IP Forwarding or Whatever it might be called. IT is different for each router. You need to forward external port 8123 to internal port 8123 on the internal IP Address of your Raspberry pi.
  2. Find your public IP Address and connect to it on port 8123. For example, if your IP address is 123.456.78.90, type 123.456.78.90:8123 into your browser. Home Assistant should load (If it doesn’t work, try disabling the wifi on your phone and connecting that way. You might only be able to connect properly if you are outside of the network).
  3. Go to www.duckdns.org 533 and login using your choice of methods at the top.
  4. Enter a name for your subdomain. For this, I will use hass-example making my full domain hass-example.duckdns.org. Don’t worry about setting your IP addresses yet.
  5. Click install 266 at the top, for their guide. Under Operating Systems, select pi and then choose the domain you’re using for your DNS.
  6. SSH into your pi.
  7. Enter the following commandsmkdir duckdns This will make a directory for the duckdns script.cd duckdns Change to the duckdns directory.nano duck.shcreate the duck dns script. Note that BRUH and DuckDNS use vi. This is stupid and more complicated than necessary.
  8. Copy the line of code from the install page and paste it into the empty file (If you are using putty, copy the text then right-click in putty to paste). It should look like this:echo url="https://www.duckdns.org/update?domains=hass-example&token=a836a8s-1337-892c-a495-ef817a92&ip=" | curl -k -o ~/duckdns/duck.log -K -
  9. Press Ctrl-XY, then ENTER to save the file.
  10. type chmod 700 duck.sh which lets the script run.
  11. run crontab -e. Copy the following text and paste it into the bottom of the crontab file. */5 * * * * ~/duckdns/duck.sh >/dev/null 2>&1
  12. Press Ctrl-XYENTER
  13. Run the script by typing ./duck.sh
  14. Check the script by typing cat.duck.log
  15. If it worked, You should see OK on the same line as [email protected]:~/duckdns $. If it says KO, something didn’t work right! Check your work and try again.
  16. type cd to return to the root directory.
  17. Make sure everything is working by connecting your duckdns domain on port 8123, such as http://hass-example.duckdns.org:8123. Remember to try while outside of your local network. If everything worked, Home Assistant should load!

Let’s Encrypt!

Home-assistant.io guide 946

Bruh-automation guide (with video) 574

  1. Open your router configurations again. You need to forward Port 80 to Port 80 on your raspberry pi, as well as port 443 to port 443 on your pi. This is to verify the certificate.
  2. Connected to your pi through SSH, run the following commandsmkdir certbot to make a directory for the SSL certification bot
    cd certbot to change to that directory
    wget https://dl.eff.org/certbot-auto to download the certbot
    chmod a+x certbot-auto to allow the certbot to run.
  3. Edit and paste in the following command to run the certbot. You need to put in your real email address and your duckdns domain../certbot-auto certonly --standalone --standalone-supported-challenges http-01 --email [email protected] -d YOURSUBDOMAIN.duckdns.org
  4. Answer the questions as it poses them to you.
  5. You should get a confirmation that everything went well and that the certificates are in the /etc/letsencrypt directory.
  6. Remove the port 443 and port 80 forwarding from your router.
  7. Type sudo chmod -R 777 /etc/letsencrypt to allow homeassistant to read the certificates.
  8. in configuration.yaml, you need to add thessl-certificate:andssl_key:lines underhttp: It should look like this http: api_password: YOUR_SECRET_PASSWORD ssl_certificate: /etc/letsencrypt/live/hass-example.duckdns.org/fullchain.pem ssl_key: /etc/letsencrypt/live/hass-example.duckdns.org/privkey.pem
  9. Try to access https://YOURDOMAIN.duckdns.org:8123 50 from outside of your local network. (note that is httpS, not http). If it connects, you did good!

Leave a Reply

Liên hệ

Hãy gọi cho chúng tôi ngay hôm nay:

Gia Lương - Việt Hùng - Đông Anh - Hà Nội

[email protected]
0968-68-9615
Select Language