How to Connect to Home Assistant Through SSH?

Connecting to your Home Assistant remotely via SSH can be helpful when you are not home. This will allow you to execute commands on your local machine remotely as if you were on your Home Assistant server. However, setting this up can be tricky. But don’t worry; this article will guide you on connecting to your Home Assistant via SSH. So, without further ado, let’s begin.

How to Set up SSH for your Home Assistant

To use SSH, you must install and set it up. Follow the steps below to set up SSH for your Home Assistant:

Step 1: Install SSH & Web Terminal

  1. First, open the Home Assistant page on your browser.
  2. Then, click on the “Supervisor” option in the sidebar.
  3. Click on “Add-on store.” This will open up the add-on store.
  4. Look for the “Terminal & SSH” add-on and click on it. You can also search for it to find it quickly.
  5. Finally, click on “INSTALL.”

terminal ssh

Step 2: Create an SSH Key

  1. Once the add-on is installed, click on the “Configuration” tab.
  2. Here, you need to enter a username, password, and authorized_keys.
  3. For the authorized_keys, you’ll need to create an SSH key.
  4. Open your Command Prompt or Terminal on your computer.
  5. In the terminal window, type the following command and hit Enter. This will generate an SSH key.

ssh-keygen

  1. Then, choose the location to save the key. Press “Enter” to save it in the default location.
  2. If the key already exists, don’t overwrite it. Instead, use the existing key.
  3. You may be asked to enter a passphrase; hit the Enter key twice to skip it for convenience.
  4. Now, check the directory for the public key using the following command:

cd ~/.ssh && ls

  1. Note the directory of the public key, open it in a text editor like Notepad, and copy the contents.
  2. Go back to the Home Assistant SSH & Web Terminal add-on configuration and add the authorized key by pasting the contents of the public key in a new line. Make sure to add a dash “-“ and white space before pasting the key.
  3. Click SAVE and then click RESTART ADD-ON to restart the add-on.
  4. Check the add-on logs from the “Log” tab to ensure it has started correctly.
  5. Scroll down, and you should see three messages— “Starting the Home Assistant STDIN service…,” “Starting the ttyd daemon…,” and “Starting the SSH daemon…”. If you see these messages, then it means that the SSH add-on has started correctly.
  6. If you get an error, you have done something incorrectly. Make sure to go back and repeat the steps to fix the error. You can continue with the next step if you don’t get an error.

Step 3: Connect to your Home Assistant

  1. Open your Command Prompt or Terminal on your computer.
  2. In the terminal window, type the following command and hit Enter. This will allow you to connect to Home Assistant via SSH. (Replace “username” with your Home Assistant’s username and “IPaddress” with your Home Assistant’s IP address.)

ssh username@IPaddress

  1. Enter your password when prompted.
  2. You are now connected to Home Assistant via SSH and can execute commands as if you were on the server.

How to Connect With SSH Directly Via Home Assistant

You can also directly add the Terminal option in the sidebar of your Home Assistant. To do this, you need to follow the steps below:

  1. First, open the Home Assistant page on your browser.
  2. Then, click on the “Supervisor” option in the sidebar.
  3. Click on “Add-on store.” This will open up the add-on store.
  4. Look for the “SSH & Web Terminal” add-on and click on it. You can also search for it to find it quickly.
  5. Finally, click on “INSTALL.”
  6.  Please wait for the add-on to install, as it may take some time.
  7. Once the add-on is installed and running, go to the “Info” tab and look for the “Show in sidebar” option.
  8. Toggle the “Show in sidebar” option to “ON”.
  9. You should now see the Terminal option in the sidebar of your Home Assistant.
  10. Click on Terminal in the sidebar, and you should be able to execute commands as you normally would.
  11. As a bonus tip, you can type the “ha help” command to see all the available commands on your home assistant.

You can watch “kian.smarthome” YouTube channel’s video below

Final Words

So that’s how to connect to your Home Assistant via SSH. In this article, we have guided you through this process in a step-by-step manner so that it’s easy for you to follow up. We hope you have successfully connected to your Home Assistant server via SSH. If you have further questions, let us know in the comments below. We will try to help you out.

Mehtab is a tech writer at DealNTech, where he covers PC and mobile-related guides and news. He is passionate about helping people understand and use technology to their advantage. In his role at DealNTech, Mehtab focuses on creating informative and engaging content on a variety of PC and mobile-related topics, including Windows, CPU, GPU, and Android. Email: [email protected]. Follow him on X(Twitter)

1 thought on “How to Connect to Home Assistant Through SSH?”

  1. For anyone else ending up here for setup (Step 3), one big change to this path to make it work.
    It actually needs to be
    ssh root@IPaddress
    and NOT using pub/private key, but password method instead.

    Reply

Leave a Comment