linuxserver / docker-openssh-server

GNU General Public License v3.0
526 stars 181 forks source link

Set the user's home directory #53

Closed tamasgal closed 2 years ago

tamasgal commented 2 years ago

linuxserver.io


Desired Behavior

Ability to set the user's home directory.

I'd like to use this Docker image to launch SSH microservices in our Docker Swarm and it would be nice if there was a way to set the user's home directory via e.g. an environment variable.

Current Behavior

The home directory is preset to /config and cannot be changed via a dynamic configuration. (At least I could not figure it out)

Alternatives Considered

Tried setting HOME in a Docker YAML file but it has no effect. I also tried setting working_dir but it seems to have no effect either.

github-actions[bot] commented 2 years ago

Thanks for opening your first issue here! Be sure to follow the bug or feature issue templates!

akzkak commented 2 years ago

+1 Also a ChrootDirectory option as an environment would be great. Plan to use this to pass out to non tech savvy friends and access to / at all would without a doubt add to there confusion.

Here you go tamasgal

https://serverfault.com/questions/499565/change-default-directory-when-i-ssh-to-server docker-compose.yml

        environment:
          PUBLIC_KEY: 'command="cd /home ; $SSH_ORIGINAL_COMMAND" ssh-rsa TTTTTrestofkeyTT== root@tttttttttttt'
aptalca commented 2 years ago

I'm afraid I don't follow you. Why would you want to change the home folder inside the container? This container is designed for a single user. Config folder is supposed to be mapped to a folder on host. So just create separate containers for each user and customize the host folder mapping for each container.

tamasgal commented 2 years ago

I thought I could reuse this for a service which gives access to an NFS share in a swarm behind a load balancer and there I'd like to chroot the user and set the home to the mounted folder.

Anyways, I went with a custom docker image and pushed it to our private registry, I guess that's the better solution. My use-case is probably too special for feature request.

neingeist commented 1 year ago

I've built a Docker Mod to do this: https://github.com/neingeist/docker-mod-openssh-server-tweaks

Glideh commented 9 months ago

I'm currently trying to use this image in order to receive some backup files through sshfs (actually the only way proposed by Borg) The current /config home also happens to expose all the config of the server which can be an issue. Chrooting the user into an empty directory would have been interesting for me too.

Glideh commented 9 months ago

Actually even without talking about sshfs, is there a way to have all the server config located elsewhere that on the user's home ?

neingeist commented 8 months ago

Actually even without talking about sshfs, is there a way to have all the server config located elsewhere that on the user's home ?

My mod https://github.com/neingeist/docker-mod-openssh-server-tweaks lets you set the home directory e.g. I use a directory different from /config for this.

But thanks for pointing out the other problem: the config in /config is exposed too. I'll have a look.