Home Assistant Community Add-on: SSH & Web Terminal

Tip for using mosh with the ssh add-on and tmux (Updated 2024-11-05)

To start a mosh session from the command line that will use tmux run:

mosh hassio@homeassistant -- sudo -i tmux a -t homeassistant

NOTE: this will share the tmux session with the web terminal.

Why is this necessary?

With the add-on, you ssh in as user hassio (a non-root user). However, the add-on has a .profile in /home/hassio that runs sudo -i to provide an interactive session running as root inside of the add-on’s container.

Since a command is being run, rather than the default of starting an interactive shell, the profile doesn’t get evaluated. So the session is running as user hassio with the wrong permissions and doesn’t /root/.zshrc which gives the familiar prompt, Oh my Zsh features, etc.

NOTE: this is why other things that use ssh like rsync run into unexpected permissions issues. rsync winds up running as user hassio and not root as expected. Copying world readable files out works fine, but copying in files can fail unless permissions are changed.


original post

[Sorry if this info is already here but I can’t find it.]

Are there tips & tricks for using this add on with mosh and tmux? It mostly works, but:

* ~/.tmux.conf doesn’t seem to get evaluated with using mosh, so the prefix key is still CTRL-B, instead of CTRL-A (or whatever I want to change it to, CTRL-)
* Creating new windows in tmux works as expected

If I manually source it using tmux -S /tmp/tmux-1000/default source-file ~/.tmux.conf:
* I get the right prefix control
* I get the right tmux status line from ~/.tmux.conf
* the Zsh prompt in the first window is ok.

However, if I create a new window PREFIX + c, the new window:
* Is created as uid=1000(hassio) gid=1000(hassio) instead of uid=0(root) gid=0(root)
* $HOME is /home/hassio instead of /root
* the Zsh prompt displays as \[\e]0;\u@\h:\w\a\]\W $

Edit: In case it matters, the way I start the mosh/tmux session is:

mosh hassio@hasshost -- tmux

(I’m running it inside of a Cygwin mintty window on Windows 11, using Cygwin’s mosh)

The problem doesn’t occur if I just use mosh to get a session, and then run tmux manually once logged in. Aside from the extra manual step, this also changes to the window title to [mosh] _zsh_tmux_plugin_run and I can no longer change it.

Hello,

my system

Debian 11 - KVM Install - haos_ova-10.3.qcow2

If i start Home Assistant Community Add-on: SSH & Web Terminal i get this error:

502: Bad Gateway

How can i solve this problem?

Solution
termnal-haos

Greets
henrya

Old thread Terminal & SSH Current version: 9.6.1 - copy & paste

is there a way to make a gpg key presistent in the addon, i have to import a gpg key everytime i restart the addon. i use a gpg key for commit signing

Hello i’m new at Home Assistant i have a raspberry 3 running HASS and have some trouble trying to install this addon.

What did wrog?
image

Edit:
Never figured out, made a fresh installation!

Have a look at:

One of the things my script does is link from the home directory to resources in /data - you can add your gpg directory .

I had to disable screen as there is an issue with alpine - explained here: GNU Screen - Bugs: bug #64190, Extremely slow startup due to fd... [Savannah] .

You need to delete the quotes out. Don’t put your password in the quotation marks, just list your password. I had the same issue until I stumbled on your post with a google search.

Hi,
Installed the add-on… success so far. But it won’t start with my username, neither with password nor ssh-key. It starts with “root” as username, but that is not recommended to use.
Log message: “FATAL: Failed creating the user account.”
Hint: I use my e-mail address as username, so it contains a @. Can that be the root of the problem?
-knut

UPDATE: Just for fun, I tried to change the username to something completely random (‘qwert’). It works like a charm. Can I use anything as username? I thougth I should use my HomeAssistant username…?

Hey all. It’s my understanding that this addon should have access to most things in the host system when running HAOS, and with protection mode disabled. Is that accurate?

I was hoping to create some command line sensors/switches to control a couple processes on a remote box using systemctl -H, but I can’t even test it because when I ssh in and try, I receive a command not found error. I assumed I was stuck in the HA container, but I was under the impression this would alleviate that (not sure if it would help the created sensors or not as they appear to run in the containierized context). I tried typing login, but there’s no password or lack thereof that is accepted. I am logging in with a ssh key, and had planned on configuring the same for the remote host.

Googling around I see plenty of examples of people creating similar sensors, but don’t know their environment.

Is this a limitation of my setup, this addon, or am I doing something stupid?

No. This addon is just a different docker container having the same “/config” than HA proper and an SSH server.

Interesting, ok, thanks.

I used to be able to copy in this terminal by holding SHIFT and selecting. Now I can no longer. Am I missing something or a configuration option that changed?

Hello, asking kindly for help or explanation since I am a noob in terms of SSH and HA.

My only and main goal is to access HA SFTP server remotely.

I installed the Advanced SSH & Web Terminal, it works just fine in the local network using the local IP. But in case I try to reach it via my purchased domain (abc.com) I get connection timeout and it does not work.

I can use my domain to reach the HA server and all of their services except SFTP.

I do not have any network firewalls or extra layers of protection.

Please let me know what I am doing wrong and where to search for help?

Your issue might be as simple as:

Option ssh: sftp

When set to true the addon will enable SFTP support on the SSH daemon. Please only enable it when you plan on using it.

Note: Due to limitations, you will need to set the username to root in order to be able to enable the SFTP capabilities.

Well sorry, but no. As I said all works perfectly fine with local IP address, so this setting is/was on. I just do not know how to make it work via Domain or public IP. Maybe I have to enter this Domain in this plugin. Or configure somehow SSL tunnel to use also port 22? Just an clueless where to search.

P.s. Settings I enabled right now to avoid any possible conflicts.But locally it works with some of those disabled too.

username: root
password: password
authorized_keys:
sftp: true
compatibility_mode: true
allow_agent_forwarding: true
allow_remote_port_forwarding: true
allow_tcp_forwarding: true

I guess I am close to a solution. I see that my public IP has open port 80 and 443 which make the http/https access work. But the port 22 and all others are closed.

So I guess this is the reason why I can not get access via SSH. But am clueless where should I configure my port. Since I use a Domain from and Namecheap registrar and CloudFlare tunnelling. Can someone give a general advice where to search and configure it?

If anyone is having issues getting this working, specifically with Windows 11, I made a YouTube video walking through the setup in under 3 minutes. Give it a try and let me know if it works for you.

How to Install Advanced SSH & Web Terminal in Home Assistant

Been using this add-on for years. I’m noticing now that when I bring up a terminal, zsh is not the default shell. I have the button installed in the HA menu and that browser based terminal is using zsh, but from the command-line, I’m not getting it anymore. I can manually launch zsh and it still has all my normal profile settings and stuff, but it’s not coming up by default.

I have debug logging turned on and here is the pertinent info from the log:

-----------------------------------------------------------
 Add-on: Advanced SSH & Web Terminal
 A supercharged SSH & Web Terminal access to your Home Assistant instance
-----------------------------------------------------------
 Add-on version: 18.0.0
 You are running the latest version of this add-on.
 System: Home Assistant OS 12.3  (aarch64 / raspberrypi4-64)
 Home Assistant Core: 2024.5.4
 Home Assistant Supervisor: 2024.05.1
-----------------------------------------------------------
 Please, share the above information when looking for help
 or support in, e.g., GitHub, forums or the Discord chat.
-----------------------------------------------------------
...
[02:52:45] NOTICE: Session sharing has been disabled!
[02:52:45] INFO: Starting the ttyd daemon...
[02:52:45] INFO: Starting the SSH daemon...
Server listening on 0.0.0.0 port 22800.
Server listening on :: port 22800.
Connection from 192.168.123.47 port 34788 on 192.168.123.205 port 22800 rdomain ""
Could not open user 'bruce' authorized keys '/root/.ssh/authorized_keys': Permission denied
Failed publickey for bruce from 192.168.123.47 port 34788 ssh2: RSA SHA256:lmjxkWDWN***************************************
Accepted key RSA SHA256:mk1qASRHcLexA9UwXZtJr**************************** found at /etc/ssh/authorized_keys:1
Postponed publickey for bruce from 192.168.123.47 port 34788 ssh2 [preauth]
Accepted key RSA SHA256:mk1qASRHcLexA9UwXZtJr************************* found at /etc/ssh/authorized_keys:1
Accepted publickey for bruce from 192.168.123.47 port 34788 ssh2: RSA SHA256:mk1qASRHcLexA9UwXZtJr********************************
User child is on pid 379
Starting session: shell on pts/0 for bruce from 192.168.123.47 port 34788 id 0

I’ve tried turning off the zsh config switch, saving, restarting, then turning it back on and restarting again, but it is still the same. I’ve also tried both settings of “shared sessions”, but still no-go.

Any ideas?

I have home assistant running at my parents’ house and I can ssh in using the SSH & Web Terminal add-on which is great thank you.
I was wondering if I could use this as a VNC jump off to be able to remotely control my Dad’s PC
Something along the lines of SSH -L 22:127.0.0.1:5901 192.168.0.42
And then I can connect a VNC client with a command like [email protected]:22

The best way to connect and fully control the remote HA instance, like being onsite, is using Zerotier or Tailscale add-on.

Thanks - sorry didn’t explain myself. I can control the HA fine. I’m looking to see if I can control a Windows PC via the HA instance