hassio-addons / addon-ssh

Advanced SSH & Web Terminal - Home Assistant Community Add-ons
https://addons.community
MIT License
345 stars 95 forks source link

zsh not starting when connecting from WSL or another Linux machine #744

Closed VlastiBroucek closed 3 weeks ago

VlastiBroucek commented 4 months ago

Problem/Motivation

After updating to 18.0.0, zsh starts correctly in web terminal, but when connecting from WSL or another Linux machine terminal, zsh does not start and sh starts automatically.

Expected behavior

In previous version both started with zsh

Steps to reproduce

Should be simple to reproduce. Noticed it first on production machine, replicated it in VMware environment. Installed initially with 17.3.0, was working. As soon as I updated to 18.0.0 stopped working.

Just to be sure, I've restored to 17.3.0 from backup and all works again as expected.

Proposed changes

Ideally fix.

mjs271 commented 4 months ago

I'm seeing the same behavior on my system when connecting via ssh, for both Linux and macOS. Once I've logged in, I can drop into a bash/zsh shell by running the command, but can't change the default shell since which chsh comes up empty handed.

rskallies commented 4 months ago

Can be fixed by running ln -s ~/.bash_profile ~/.profile when logged in

VlastiBroucek commented 4 months ago

Can be fixed by running ln -s ~/.bash_profile ~/.profile when logged in

That did not work for me...

rskallies commented 4 months ago

Yes for me it also did not work as expected. I then just changed the root user shell /etc/passwd from /bin/sh to /bin/zsh and now it works until the add-on is restarted. root:x:0:0:root:/root:/bin/sh vs. root:x:0:0:root:/root:/bin/zsh

VlastiBroucek commented 4 months ago

Yes for me it also did not work as expected. I then just changed the root user shell /etc/passwd from /bin/sh to /bin/zsh and now it works until the add-on is restarted. root:x:0:0:root:/root:/bin/sh vs. root:x:0:0:root:/root:/bin/zsh

Which means the add-on is broken and sadly, the maintainer keeps quiet...

rskallies commented 4 months ago

Indeed. The commit 629ed2041233b1916ad54fd89ee2afe62b28d2c3 updated the base image to Alpine 3.20.0. In this Alpine base image there is no /bin/ash in the password file entry for the root user anymore. It has now the more common /bin/sh value. The add-on tries to change it from /bin/ash to /bin/zsh which does not work anymore. The issue is located in the Dockerfile at line 87 "&& sed -i -e "s#bin/ash#bin/zsh#" /etc/passwd" .

Dockerfile.patch

MilesTEG1 commented 3 months ago

Can be fixed by running ln -s ~/.bash_profile ~/.profile when logged in It worked for me. Until the add-on is restarted...

Indeed. The commit 629ed20 updated the base image to Alpine 3.20.0. In this Alpine base image there is no /bin/ash in the password file entry for the root user anymore. It has now the more common /bin/sh value. The add-on tries to change it from /bin/ash to /bin/zsh which does not work anymore. The issue is located in the Dockerfile at line 87 "&& sed -i -e "s#bin/ash#bin/zsh#" /etc/passwd" .

Dockerfile.patch

How can I use this fix? I'm running HAOS and the addon inside HA.

jcwillox commented 3 months ago

I found that adding shadow to the packages option, (which adds the chsh command to change default shell), and adding chsh -s /bin/zsh to init commands successfully changes the default shell. I don't know why this is needed now but at least it fixes the issue for the time being.

packages:
  - shadow
init_commands:
  - chsh -s /bin/zsh
MilesTEG1 commented 3 months ago

Nice fix @jcwillox It seems to be working fine.

I just realized that all my .zshrc personnalisation was gone after rebooting the addon... my nice prompt... Where can I store my file in order to get it back after a reboot?

jcwillox commented 3 months ago

I'm not sure if there's an official way, but my suggestion would be to put it in one of the mounted folders e.g. /config or /share and add a symlink to it ln -s /share/.zshrc ~/.zshrc you might also need -f to override the existing file, (or just rename it beforehand). Alternatively you can use a dotfiles manager to setup and sync your configs between devices.

github-actions[bot] commented 2 months ago

There hasn't been any activity on this issue recently, so we clean up some of the older and inactive issues. Please make sure to update to the latest version and check if that solves the issue. Let us know if that works for you by leaving a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thanks!

Bert-R commented 2 months ago

This issue is still active. There's a workaround (https://github.com/hassio-addons/addon-ssh/issues/744#issuecomment-2157120538), but it is not resolved.

github-actions[bot] commented 1 month ago

There hasn't been any activity on this issue recently, so we clean up some of the older and inactive issues. Please make sure to update to the latest version and check if that solves the issue. Let us know if that works for you by leaving a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thanks!

Bert-R commented 1 month ago

This issue is still active

VlastiBroucek commented 1 month ago

💯 %

VlastiBroucek commented 3 weeks ago

This is now resolved in 19.0.0 Closing the issue