How To Connect to Home Assistant via SSH

by Danny
7 comments

READING TIME: 3 MINUTES

In this guide, I’ll show you how to access Home Assistant via SSH. While I’ve personally never had the need for this, there are some instances where remote SSH access may be needed. So, this tutorial I will walk you through the process.

Let’s get started!


Step 1: Enable SSH Access

Click your profile in Home Assistant.

Toggle Advanced Mode on if it isn’t already.

Step 2: Install SSH Addon

Next, go back to Home Assistant > Supervisor > Dashboard. If Terminal & SSH isn’t already installed, click the Add-on Store tab to install it.

Click the Configuration tab at the top.

Enter a password into the Password field and save.

Under Network, set the port to 22, and then click Save.

It will prompt you to restart your addon afterwards.

Once installed and a password has been set, click the Info tab to start the addon.


Step 3: Connect to Home Assistant via Putty

Launch the SSH tool of your choice (I’m using Putty). For the Host Name, type the hostname or IP of Home Assistant and enter 22 for the port.

The first time you connect to it, a box will popup asking if you trust the host. Click Yes.

Login credentials: Root / the password you created in Terminal & SSH addon.

Now, you should be connected to HA via SSH!


Step 4: Navigate & Edit Configuration Files

To start editing some of your files, such as configuration.yaml, use the following commands:

cd /config

This will change to the root directory. This would be the same as if you clicked File Editor from within Home Assistant. Then, edit your configuration.yaml file by typing:

nano configuration.yaml


Wrapping Up

That’s all there is to it to access Home Assistant from an SSH client! If you don’t use Putty, or want a cleaner way to SSH into Home Assistant, there are some VSCode extensions for SSH (Remote-SSH being my favorite).

I don’t necessarily recommend editing your config files from SSH as there are much better ways of doing it. After all, for security purposes, SSH is disabled by default in Home Assistant. SSH access should be reserved for emergency situations, such as to reboot HA remotely or edit a config file if you’ve made a syntax error and need to edit something to get Home Assistant to launch.

A much better method of editing config files is by creating a Samba file share and accessing Home Assistant through Visual Studio Code editor, or by installing the Visual Studio Code add-in within Home Assistant so you can get the full power of VSCode in a browser.

If you are just testing it out, or don’t plan to use SSH access, I highly recommend disabling it completely afterwards just so you don’t forget that it’s still active.


My Favorite Home Assistant Devices

Below are some of the Home Assistant-compatible devices I personally use in my home. I highly recommend each of them.

The full list of all Home Assistant compatible & recommended devices I use can be found on my Equipment List page.

Smart Home Product Finder

What hub do you currently use?


SmartThings

Home Assistant

Hubitat

Step 1 of 3

What product are you looking to add?


Lights

Locks

Thermostats

Cameras

Garage Door Opener

Switches

Sensors

Motion, Door & Window, Leak

Smart Plugs

Buttons

Step 2 of 3

What protocol?


Z-Wave

Zigbee

Wifi

Step 3 of 3

Retake quiz? Click here!

7 comments

You may also like

7 comments

Tom December 16, 2021 - 6:49 am

Hi Danny. I am new to HA and just setup SSH access per your guide. However, I need to install HACS and it says to change to the user that runs HA, which is my personal user (created on install). But I cannot get SU or SUDO to work at all, it says “unknown user”, even though it is the same name as I use inside HA. Have you had to change user context in SSH and know any tricks to make it work. I doubt installing HACS under “root” will work.

Reply
Scptt January 20, 2022 - 5:37 pm

“Supervisior” is now “Configurations / Add-ons, Backups & Supervisor”. Diagnosing a “502 Bad Gateway” error… any suggestions appreciated!

Reply
HillSonMX March 4, 2022 - 3:56 pm

Hope help anyone else:
I can make it work go for user: root and passwork (Enter a password into the Password field)

Reply
Ankit March 22, 2022 - 12:41 am

Thanks for this blog, it was very helpful…

Reply
Ankit March 22, 2022 - 12:46 am

Hey Danny, you know if there is a possibility of installing containers inside home assistant OS for x86. There are many integration which needs to be installed as containers. Can you please suggest?

Reply
Steve July 9, 2022 - 9:44 am

I don’t see anywhere in your instructions where to generate or save ssh keys?

Reply
Danny July 9, 2022 - 10:25 am

You don’t need to generate a key. You just enable SSH access and then log into Home Assistant using an SSH tool like Putty. Credentials are Root and whatever password you set

Reply

Leave a Comment