Use GNU Screen & more with `Terminal & SSH` add-on

I thought some may be interested in my ‘Terminal & SSH’ setup on HAOS.

By using GNU Screen, the previous session is recovered so that you can disconnect and reconnect without “losing” your history/view.
I also add a status line and some other configurations to increase efficiency.

You would need to learn screen “a bit”, but the principal key sequence to learn is CTRL-A d which disconnects from the session without closing it.

You can find my setup in a Gist on github .

Home Assistant “Terminal & SSH” screen configuration.

Purpose

  • Start gnu screen automatically
    when connecting interactively to Home Assistant (keep terminal session
    across connections).
  • Provide a status line in the terminal
  • Define some aliases
  • Automatically “re-install” after add-on upgrade (create symbolic links,
    .vimrc, .viminfo)
  • Use vim when calling vi

How to

  • These files reside in /data
  • The “Terminal & SSH” add-on automatically relinks the .bash_profile
    script (see /etc/cont-init.d/profile.sh )
  • Add the appropriate apks to your “Terminal & SSH configuration”. This is
    what my configuration looks like. You only need the ‘screen’ apk, I
    suggest the other ones (database access, install python modules):
authorized_keys:
  - >-
    ssh-rsa
    PRIVATE_KEY PRIVATE_ALIAS
password: ''
apks:
  - screen
  - etckeeper
  - sqlite
  - py3-pip
server:
  tcp_forwarding: false

:warning: For an unknown reason, screen is broken on HAOS since quite a while - for some reason it tests all potential descriptors to find terminals which takes a very long time.
So I disabled it for the time being. I filed a bug report to GNU Screen, but I’ld need to follow up on it.
Maybe I’ll switch to tmux - which is already possible for anyone else ;-).