Certbot not found
Asked Answered
C

7

12

i installed letsencrypt on my ubuntu 16.04 machine with following command.

sudo apt-get install letsencrypt

Now, i want to define a cronjob to automatically renew my certs with following line.

certbot renew --pre-hook "service nginx stop" --post-hook "service nginx start"

But i always get the error, that the command certbot could not be found.

If i use letsencrypt instead of certbot everything works fine as long as i dont use the --pre-hook and --post-hook.

How to install certbotor is there an alternative command for letsencrypt to define such hooks?

Thanks

Casmey answered 21/10, 2016 at 11:26 Comment(0)
C
5

Ok i found the solution..

git clone [email protected]:certbot/certbot.git

cd certbot

./certbot-auto renew --pre-hook "service nginx stop" --post-hook "service nginx start"

Casmey answered 24/10, 2016 at 10:2 Comment(2)
It is good practice to install certbot via python package manager pip: pypi.python.org/pypi/certbot/0.17.0. Latest Ubuntu 17.04 (Zesty) has certbot in it's repository as well.Requirement
root@f114791e9f83:/certbot# ./certbot-auto bash: ./certbot-auto: No such file or directoryBelamy
I
22

For me the following commands working fine.

Install snap

sudo apt update

sudo apt install snapd

Install Core

sudo snap install core

Install Certbot

sudo snap install --classic certbot

sudo ln -s /snap/bin/certbot /usr/bin/certbot

Renew Certbot

sudo certbot renew --dry-run
Intricacy answered 16/3, 2021 at 7:3 Comment(2)
Ran those and got: "certbot: command not found"Forworn
I got >>snap "certbot" is not available<<Proportionable
H
8

Follow the official instructions and install certbot with

sudo snap install --classic certbot

or, in older Ubuntus that don't have snap, with

sudo apt install certbot python3-certbot-nginx

It will be available in $PATH after that.

Handedness answered 30/7, 2020 at 13:41 Comment(1)
Oh man, this is the perfect answer. Follow official instructions. I didn't and suffered.Svend
C
5

Ok i found the solution..

git clone [email protected]:certbot/certbot.git

cd certbot

./certbot-auto renew --pre-hook "service nginx stop" --post-hook "service nginx start"

Casmey answered 24/10, 2016 at 10:2 Comment(2)
It is good practice to install certbot via python package manager pip: pypi.python.org/pypi/certbot/0.17.0. Latest Ubuntu 17.04 (Zesty) has certbot in it's repository as well.Requirement
root@f114791e9f83:/certbot# ./certbot-auto bash: ./certbot-auto: No such file or directoryBelamy
C
1

This worked for me. I have to specify full path when running certbot with elevated privileges

sudo /snap/bin/certbot renew --dry-run

TL;DR

Although I have /snap/bin in my $PATH

echo $PATH

/usr/local/bin:/usr/bin:/bin:/usr/games:/snap/bin

But without providing full path it does not work with sudo. It throws the following error

certbot renew --dry-run
The following error was encountered:
[Errno 13] Permission denied: '/var/log/letsencrypt/.certbot.lock'
Either run as root, or set --config-dir, --work-dir, and --logs-dir to writeable paths.

and it also works if I (while having /snap/bin in root's $PATH as well) switch to power user

sudo -i

and then run any certbot command

Kindly note I'm on debian 10 and using snapd as package manager according to the tutorial https://certbot.eff.org/lets-encrypt/snap-nginx.

As explained here https://unix.stackexchange.com/questions/245772/why-running-command-as-sudo-returns-command-not-found this is kinda expected and approved of behaviour:

sudo tries to be safe when executing external commands. the usual workaround is to specify the complete pathname of the program. It's also more secure; it you don't specify the path, it's conceivable that an attacker could create another program that will be run with root permissions.

Going on reading further I can see that my PATHs are different

env | grep ^PATH
sudo env | grep ^PATH

There are several solutions (use custom sudo or change sudo $PATH) provided at the thread Command not found when using sudo so one does not have to specify full path.

Chaudoin answered 12/7, 2020 at 9:37 Comment(0)
O
1

try to remove using snap
sudo snap remove certbot

and then install again with sudo snap install --classic certbot

Ostraw answered 7/1, 2021 at 11:21 Comment(0)
T
0

You can try Let's Certbot.

Let's Certbot is a tool builds automated scripts base on Certbot for obtaining, renewing, deploying SSL certificates.

It supports docker and non-docker environments.

GitHub: https://github.com/jinhucheung/letscertbot

Tantalize answered 6/2, 2020 at 3:4 Comment(0)
M
0

try this sudo ~/.certbot/bin/certbot certonly --webroot

Maxwell answered 24/1, 2022 at 6:43 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.