addon-ssh icon indicating copy to clipboard operation
addon-ssh copied to clipboard

zsh not starting when connecting from WSL or another Linux machine

Open VlastiBroucek opened this issue 1 year ago • 15 comments

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.

VlastiBroucek avatar May 28 '24 04:05 VlastiBroucek

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.

mjs271 avatar May 31 '24 03:05 mjs271

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

rskallies avatar Jun 03 '24 18:06 rskallies

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

That did not work for me...

VlastiBroucek avatar Jun 04 '24 09:06 VlastiBroucek

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

rskallies avatar Jun 04 '24 15:06 rskallies

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...

VlastiBroucek avatar Jun 05 '24 08:06 VlastiBroucek

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

rskallies avatar Jun 05 '24 18:06 rskallies

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.

MilesTEG1 avatar Jun 08 '24 19:06 MilesTEG1

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

jcwillox avatar Jun 10 '24 03:06 jcwillox

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?

MilesTEG1 avatar Jun 10 '24 11:06 MilesTEG1

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.

jcwillox avatar Jun 10 '24 12:06 jcwillox

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!

github-actions[bot] avatar Jul 11 '24 08:07 github-actions[bot]

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.

Bert-R avatar Jul 11 '24 18:07 Bert-R

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!

github-actions[bot] avatar Aug 12 '24 08:08 github-actions[bot]

This issue is still active

Bert-R avatar Aug 12 '24 20:08 Bert-R

💯 %

VlastiBroucek avatar Aug 12 '24 22:08 VlastiBroucek

This is now resolved in 19.0.0 Closing the issue

VlastiBroucek avatar Sep 12 '24 03:09 VlastiBroucek