Overriding sshd_config in SSH App

,

A minor frustrating thing for me with the Advanced SSH app is it disconnects pretty quickly. SSH running on my other machines don’t disconnect so I was curious about altering that behavior. That app has ClientAliveInterval & ClientAliveCountMax set (which is not the default).

Whether changing that is a good idea or not isn’t really the question. (And this poking around is all in a sandbox HAOS.)

But looking at this led to questions:

  • If I wanted to change the sshd_config is the solution to run my own version of sshd via /addons (or a feature request)?

And this gets into the weeds a bit:

  • If I modify /etc/sshd_config and restart the app (ha apps restart a0d7b954_ssh) the config gets reset. I’ve modified things in other containers and restarted (e.g. ha core restart) and the changes persist (until an update). Are apps restarted differently or did I miss in the Dockerfile where it is copied fresh?

I’m just trying to get a better understanding of how the mechanics work.

Another mildly annoying thing is up update I lose my history. Anyone know a fix for this?

System is ready! Use browser or app to configure.
zsh: corrupt history file /root/.zsh_history

Having history persist across updates would be handy – which I assume was intended because that’s why it’s in /root/.

You can certainly do a git clone from the ssh app to addons, and change the config.yaml and Dockerfile and make the settings you want and build the image locally. You have to remove the image tag from the config.yaml file so you don’t downloading the image from the net.

Yeah, that’s pretty easy. Copied config.yaml and added a Dockerfile:

➜  ~ cat /addons/ssh/Dockerfile
FROM ghcr.io/hassio-addons/ssh:24.0.1
RUN \
    sed -i \
    -e 's/^ClientAliveInterval/#ClientAliveInterval/' \
    -e 's/^ClientAliveCountMax/#ClientAliveCountMax/' \
    /etc/ssh/sshd_config

I will have to manually trace upstream updates.

Not quite sure why the logo and icon are not showing up:

I copied them from the repo:

➜  ~ ls -l /addons/ssh
total 480
-rw-r--r--    1 root     root           195 Aug  2 14:32 Dockerfile
-rw-r--r--    1 root     root          1668 Aug  2 14:46 config.yaml
-rw-r--r--    1 root     root        237777 Aug  2 14:34 icon.png
-rw-r--r--    1 root     root        237807 Aug  2 14:35 logo.png

Trying to move .bash_profile to /root. I’ve got this in my Dockerfile:

root@local-ssh /addons/ssh $ fgrep profile Dockerfile
COPY .bash_profile /root/.bash_profile
COPY .bash_profile /tmp/
RUN cp /tmp/.bash_profile /root

root@local-ssh /addons/ssh $ echo $HOME
/root

And when I update the version and update I only get this:

root@local-ssh /addons/ssh $ docker exec -it app_local_ssh find / . -name .bash_profile
/tmp/.bash_profile
/addons/ssh/.bash_profile
./tmp/.bash_profile
./addons/ssh/.bash_profile

Any idea how to get .bash_profile to $HOME?

As a workaround, this works, but curious why the above doesn’t work:

COPY .bash_profile /etc/profile.d/zbash_profile.sh

When running this command you running it in a running container, is that the container that you build with your changes.

docker ps -a --format "table {{.ID}}\t{{.Names}}\t{{.Status}}\t{{.CreatedAt}}"

Yes, and it’s a bit of a silly example (since I’m already in that container), I was just being explicit which container I was looking at.

The problem appears to simply being the parent containers startup removes .bash_profile. If I use say:

COPY .bash_profile /root/.bash_profile
COPY .bash_profile /root/foo_bash_profile

then only foo_bash_profile ends up in /root.

if ! bashio::config.true 'share_sessions'; then
    bashio::log.notice 'Session sharing has been disabled!'
    rm /root/.bash_profile
    rm /root/.zprofile
fi

I’m not clear why those would be remove when session sharing is not enabled.

The question would be, why do you need to change the bash_profile file ?
Isn’t it better that you contact the developer of the ssh app or write a PR?

Well, that wasn’t my question, and I’m not sure how to measure “better”. :wink:

It’s not just .bash_profile. It was to change sshd_config before sshd starts as described in the first post – and to learn more about the app mechanics.

The developer is Franck, and, besides being somewhat occupied with other things, I assume he changed the default sshd_config behavior 9 years ago on purpose.

But if you follow my first advice, from the beginning.

You make a git clone to the addons directory and then remove the build.yaml file.
Change the sshd_config file which is under the rootfs/etc directory.

Build your own ssh image yourself and not download the already built image.
And change the slug: ssh in config.yaml, to your own name, so you don’t make a collision.

Not a huge difference, right? Still have to build off of a parent container, and doing this is just making a few changes to the existing app. Sure, I could just build it all locally.

Local apps have local_ prefixed to the slug so that doesn’t seem to be an issue – I was running both at the same time for a while.

What ? from what parent ? In the Dockerfile it from the base:
https://github.com/hassio-addons/app-ssh/blob/a08566f0e1bc10b348577571dcef520fd564b995/ssh/Dockerfile#L1

Ha! I was wondering if you were going to point out I said “parent”. :wink:

FROM ghcr.io/hassio-addons/ssh:24.0.1