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

"Permission denied (publickey)" when running in docker #5623

Closed
2 of 7 tasks
MoshiBin opened this issue Jan 2, 2019 · 2 comments · Fixed by #5624
Closed
2 of 7 tasks

"Permission denied (publickey)" when running in docker #5623

MoshiBin opened this issue Jan 2, 2019 · 2 comments · Fixed by #5624
Labels

Comments

@MoshiBin
Copy link
Contributor

MoshiBin commented Jan 2, 2019

  • Gitea version (or commit ref): f5be13e
  • Git version: Doesn't matter
  • Operating system: Any
  • Database (use [x]):
    • PostgreSQL
    • MySQL
    • MSSQL
    • SQLite
  • Can you reproduce the bug at https://try.gitea.io:
    • Yes (provide example URL)
    • No
    • Not relevant
  • Log gist:

Description

After setting up gitea on Docker using a user called "gitea", creating a user and adding its public key, cloning fails with the Permission denied (publickey) error.

I looked into this and found something strange - in /etc/ssh/sshd_config, the AllowedUsers directive showed giteaea instead of gitea. In fact, every time I restarted the container, the user gained another "ea" at the end - so it went to giteaeaea etc. Changing the directive back to gitea manually doesn't help, because during startup it changes to giteaea.

My workaround: I copied /etc/ssh/sshd_config from the container to the host, and bound it into the container, setting the :ro flag so it would be immutable.

@techknowlogick
Copy link
Member

Did you pass the USER environment variable to the container?

If yes, then it is likely because of this line:

sed -i -e "s/AllowUsers git/AllowUsers ${USER}/g" /etc/ssh/sshd_config
It seems the regex should grep for AllowUsers git on a line, instead of search for that string where it could be the middle.

MoshiBin added a commit to MoshiBin/gitea that referenced this issue Jan 2, 2019
@MoshiBin
Copy link
Contributor Author

MoshiBin commented Jan 2, 2019

Thanks for the quick response! Posted a pull request 😄

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

Successfully merging a pull request may close this issue.

2 participants