Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Permissions issue with authorized_keys #7

Open
sarahnyxx opened this issue Jun 15, 2021 · 2 comments
Open

Permissions issue with authorized_keys #7

sarahnyxx opened this issue Jun 15, 2021 · 2 comments

Comments

@sarahnyxx
Copy link

There's an issue with this line of the docker-compose.yml file:

- $PWD/authorized_keys:/var/lib/bastion/authorized_keys:ro

Mounting the authorized_keys file will cause a problem with UID/GID mapping within the container. When I opened an sh session with docker exec -it bastion /bin/sh and poked around, I discovered that the file is marked with owner and group "1000" (Matching my user on the docker host system I used to run docker-compose up -d).

The sshd daemon will only use the authorized_users file to allow a user to login only if the file is owned by the user being logged in. Being owned by root, or by a UID other than bastion's 4096 causes the SSH client to return Permission denied (publickey, keyboard-interactive).

I debugged this by modifying my docker-compose.yml to mount the authorized_keys file as read-write, and via sh inside the container, to chown bastion:bastion /var/lib/bastion/authorized_keys. After these steps were taken, I was able to login with an ssh client.

Another solution is to sudo chown 4096:4096 authorized_keys from the docker host itself to match the UID/GID to the user in the container, and is probably the better solution. However, this is not documented at all in the README.md

Perhaps I'm just missing an otherwise intuitive understanding that prevents this issue, but passing this along as something I experienced.

Thanks

@jimmysyss
Copy link

sudo chown 4096:4096 authorized_keys also works for me on AWS ECS.

It will be awesome if this image can run on AWS Fargate

@gbarros
Copy link

gbarros commented Nov 24, 2021

I had an issue with access to the authorized_keys file, so I solved it as this StackOverflow suggested.

sudo chmod 600 authorized_keys

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants