VS Code remote

I found another SSH plugin for VSCode that made the trick. Try if it works @ajayjohn

2 Likes

Still using this addon?
I try to connect to HA but get error message “Error while connecting to SSH FS homeassistant: Handshake failed: no matching client->server HMAC”

Everything works when I ssh to HA with terminal with the same credentials

1 Like

@hoogen Can you hare some info on how to get this setup?

1 Like

There is an add-on that provides VSCode Remote in Hassio’s edge repository . I’ve been using it for the past week and it works well.

Sorry no, havn’t used this exept some testing about a year ago.

You don’t know how helpfull this has been.

sshfs (on vs code) + Terminal & SSH (on my home assistant rpi4)

2 Likes

That’s nice!

This can be achieved with the SSH & Terminal addon that many likely already have.

Here’s the required configuration parameters (everything else is à votre gout)

Visual Studio Code Remote - SSH

Some customization is required prior to being able to connect to your Home Assistant install with Visual Studio Code. The following configuration will aid in setting up VSCode Remote - SSH:


packages:
  - gcompat
  - libstdc++
  - curl
allow_remote_port_forwarding: true
allow_tcp_forwarding: true

Notes

  • Allowing remote port and tcp forwarding lower the overall level of security of your SSH server. Nevertheless, this warning is debatable.
  • It is not required to disable protection mode for this to work correctly.
  • The Studio Code Server addon is not required for this to work correctly.
  • This will not work through Home Assistant Cloud. LAN only unless you’ve exposed your server directly to the internet.
3 Likes

Many thanks, @brandonnolet. I was fiddeling around for a long time but could not get this to work. With your config snippet, I finally got the VS Remote SSH setup working!

1 Like

The configuration to get this to work was slightly different for me, the Terminal & SSH yaml should look something like this.

apks:
  - gcompat
  - libstdc++
  - curl
server:
  tcp_forwarding: true
  remote_port_forwarding: true
2 Likes

allow_remote_port_forwarding doesn’t seem to be valid anymore.

Otherwise has been functional for me. Though, I still get The remote host may not meet VS Code Server's prerequisites for glibc and libstdc++.

No idea if this error is breaking anything, but I haven’t yet noticed it if so.

Is this config correct?

Hey all. In trying to get this working I felt like it was all just throwing spagetti at a wall. So I went about figuring out how all this works.

This VS Code docs page describes the prerequisite libraries preinstalled for each linux distribution.

Running cat /etc/os-release in the HomeAssistant SSH terminal results in this.

NAME="Alpine Linux"
ID=alpine
VERSION_ID=3.17.3
PRETTY_NAME="Alpine Linux v3.17"
HOME_URL="https://alpinelinux.org/"
BUG_REPORT_URL="https://gitlab.alpinelinux.org/alpine/aports/-/issues"

So HA runs in Alpine Linux.

From the vscode docs, these are the packages build into the OS.

And they state:

The extensions are known to work when connecting to recent stable/LTS version of:
- Ubuntu 64-bit x86, ARMv8l (AArch64) (16.04+, IoT 18.04+)
- Debian 64-bit x86, ARMv8l (AArch64) (Stretch/9+)
- Raspberry Pi OS ARMv7l (AArch32) 32-bit (Stretch/9+) (previously called Raspbian)
- CentOS / RHEL 64-bit x86 (7+)
- Alpine Linux 64-bit x86 containers or WSL hosts (3.9+) in Dev Containers, WSL

So, all we should have to do is connect and it should work. But, it doesn’t.
Turns out we do need glibc but it’s not part of Alpine Linux.

That leads to gcompat.

gcompat, is a library which provides glibc-compatible APIs for use on musl libc systems.

Basically, gcompat provides glibc for Alpine.

So, this is the config that works for me.

authorized_keys: []
password: ThisIsMyPassword
apks:
  - gcompat
server:
  tcp_forwarding: true
  remote_port_forwarding: true

And when VS Code attaches it throws the “can’t find glibc” warning because glibc doesn’t actually exist, gcompat does.

From the connection console output in VS Code…
SCR-20231018-rznc

I think this explains everything that is going on. We’re able to connect and can safely ignore the missing lib warnings. :+1:

Best,
Jeremy

5 Likes

Thanks, it’s work with my raspberry pi 3.

1 Like

Is it possible to disable the
The remote host may not meet VS Code Server's prerequisites for glibc and libstdc++
warning at connection in VScode?

Read the last part of my post to see why that isn’t possible.

1 Like

This setup stopped working for me, I suspect due to recent changes in Vscode more info.

At the moment the only suggested option seems to be downgrading Vscode :face_with_peeking_eye:

Hello, I confirm that the issue is on VS Code’s side with the 1.86.0 update.
See my post in another thread for related information, followed by the modus operandi to downgrade, and a workaround further down the discussion that you might wish to try.

Happy to report that VS Code 1.86.1 update that was released on Feb. 8th has solved the issue, enabling again to connect to HA instance over SSH.

How to install the upgrade:

  1. Launch VS Code desktop version 1.85.2.
  2. Go to Settings and change the “update mode” setting back to ‘default’. This will require a restart of VS Code.
  3. After restarting VS Code, execute Code / Check for updates… (on Mac). This will download the 1.86.1 version and prompt another restart.
  4. After restarting again, the “Remote - SSH” extension should prompt an update to version 0.108.0. Be sure to select “auto-update” for this extension.

Note Microsoft’s position here:

We have discussed this more in the VS Code team and we have decided to allow VS Code to connect to an OS that is not supported by VS Code (no support for glibc >= 2.28) for 12 more months .
We hope this will provide the needed time for you and your companies to migrate to newer Linux distributions.

So while the issue is solved in the short term, we still need a proper solution for the longer term.

Cheers!

This was the solution for me: How to connect local VSCode instance to VS Code HA Add-on via ssh? - #36 by Nexxado