I am creating a docker container that will host a web app. The container is an ubuntu18.04 vm with a flask app + gunicorn running. I am trying to configure ssh but something wonky is going on.
In my docker file I do something along the lines of:
RUN useradd -s /bin/bash -m username
This works fine and the user gets added. I have a separate process that run-in the background and adds to the /home/username/.ssh/authorized_keys to allow for password less ssh. Again this works, the weirdness comes in when the actual ssh happens.
When I ssh in I see that $HOME is set to /root instead of /home/username. If I try to cd ~/ it gets an access denied because it is trying to go to /root. Why is HOME incorrect but I am connected as the correct user?
Note: in the below output I changed the username as it is a bit identifying
Output:
Welcome to Ubuntu 18.04.5 LTS (GNU/Linux 4.15.0-112-generic x86_64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage
This system has been minimized by removing packages and content that are
not required on a system that users do not log into.
To restore this content, you can run the 'unminimize' command.
Last login: Thu Feb 11 17:38:55 2021 from 172.16.1.7
-bash: /root/.bash_profile: Permission denied
username@bb29610ab373:/username/app$
username@bb29610ab373:/username/app$ cd ~
-bash: cd: /root: Permission denied
The user in passwd file:
username@bb29610ab373:/username/app$ cat /etc/passwd | grep username
username:x:1000:1000::/home/username:/bin/bash
This is confusing the heck out of me. Any help would be appreciated.