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

Using dokku-acl with dokku-letsencrypt breaks auto-renewal #22

Open
Shark opened this issue Nov 7, 2018 · 6 comments · May be fixed by #37
Open

Using dokku-acl with dokku-letsencrypt breaks auto-renewal #22

Shark opened this issue Nov 7, 2018 · 6 comments · May be fixed by #37

Comments

@Shark
Copy link

Shark commented Nov 7, 2018

We use dokku-acl together with the dokku-letsencrypt plugin. For auto-renewal of certificates, the plugin creates a cronjob for the dokku-User:

@daily /var/lib/dokku/plugins/available/letsencrypt/cron-job

which in turn executes

dokku letsencrypt:auto-renew &>> /var/log/dokku/letsencrypt.log

which fails on our hosts:

User default does not have permissions to run letsencrypt:auto-renew
Access denied

What would be the best way to fix this issue? I thought about some ways, but I didn't find one which works well...

  1. We've set export DOKKU_SUPER_USER=dokku. So if the cronjob would export NAME it should work, right?
  2. We could add letsencrypt:auto-renew to DOKKU_ACL_USER_COMMANDS. But since letsencrypt:auto-renew calls letsencrypt and certs:add, we would need to whitelist those functions for all apps as well, which is undesirable.
@josegonzalez
Copy link
Member

Sorry for getting to this so late:

  • Can you turn on events via dokku events:on, trigger the cronjob - don't run letsencrypt directly! - and show the output of /var/log/dokku/events.log? It should contain the user that the cronjob is running as. It's possible it is running as root or something.

@Shark
Copy link
Author

Shark commented Dec 7, 2018

Thanks for your reply!

I did the following:

  • enabled dokku events
  • edited dokku's crontab to run the letsencrypt cron-job in the next minute

/var/log/dokku/events.log:

Dec  7 11:01:01 app2 dokku[21011]: INVOKED: user-auth(  default letsencrypt:auto-renew ) NAME= FINGERPRINT=
Dec  7 11:01:02 app2 dokku[21647]: INVOKED: user-auth(  default letsencrypt zweitag-shoebox ) NAME= FINGERPRINT=

/var/log/dokku/letsencrypt.log:

=====> Auto-renewing all apps...
-----> test-app needs renewal
User default does not have permissions to run letsencrypt
Access denied

@josegonzalez
Copy link
Member

Where is the crontab file specified?

@Shark
Copy link
Author

Shark commented Dec 12, 2018

I edited the crontab w ith sudo crontab -u dokku -l to look like this:

# @daily /var/lib/dokku/plugins/available/letsencrypt/cron-job
00 09 * * * /var/lib/dokku/plugins/available/letsencrypt/cron-job

@josegonzalez
Copy link
Member

The default username for dokku is default. This will be used if the NAME environment variable isn't set. We don't default that to dokku but maybe we should?

If we did, that wouldn't break anything in dokku core, and the acl plugin would continue working as expected (the logged in dokku would work), just we would enable background jobs to work.

Anyone have any thoughts on this?

@Cellane
Copy link

Cellane commented Mar 26, 2020

I think that makes sense, I’d appreciate the rename of the default Dokku’s username to dokku.

I found this issue a few days ago when I was investigating the difficulties of allowing my friend to host his website on my server. I spent some time testing if the reported issue is still a problem nowadays, and came up to the conclusion that as long as your SSH key is called default, and your super-admin username is set to default, you’ll be able to renew LE certificates from cron, access all commands as expected when you have direct access to the server’s SSH and when interacting with Dokku remotely.

But definitely renaming the user from default to dokku would have felt cleaner.
(Alternatively – or in addition – it would’ve been nice to be able to specify multiple super-admin accounts – but perhaps that’s a different issue altogether)

RealOrangeOne added a commit to RealOrangeOne/dokku-acl that referenced this issue Apr 10, 2023
This not only makes running commands manually much simpler, but removes some confusion around "dokku" / "default" user as the superuser (some places need both).

Fixes dokku-community#22
Fixes dokku-community#36
@RealOrangeOne RealOrangeOne linked a pull request Apr 10, 2023 that will close this issue
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

Successfully merging a pull request may close this issue.

3 participants