未找到 Certbot

问题描述 投票:0回答:7

我使用以下命令在我的 ubuntu 16.04 机器上安装了 LetsEncrypt。

sudo apt-get install letsencrypt

现在,我想定义一个 cronjob 以使用以下行自动更新我的证书。

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

但我总是收到错误,无法找到命令 certbot。

如果我使用letscrypt而不是certbot,只要我不使用

--pre-hook
--post-hook
,一切都可以正常工作。

如何安装

certbot
或者是否有替代命令让LetsEncrypt来定义此类挂钩?

谢谢

ssl ubuntu-16.04 lets-encrypt certbot
7个回答
19
投票

对我来说以下命令运行良好。

安装卡扣

sudo apt update

sudo apt install snapd

安装核心

sudo snap install core

安装Certbot

sudo snap install --classic certbot

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

续订 Certbot

sudo certbot renew --dry-run

7
投票

按照官方说明并安装

certbot

sudo snap install --classic certbot

或者,在没有

snap
的较旧 Ubuntu 中,有

sudo apt install certbot python3-certbot-nginx

此后将在

$PATH
提供。


5
投票

好吧,我找到了解决方案..

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

cd certbot

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


1
投票

这对我有用。以提升的权限运行 certbot 时,我必须指定完整路径

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

TL;博士

虽然我的 $PATH 中有 /snap/bin

echo $PATH

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

但是如果不提供完整路径,它就无法与

sudo 一起使用。它抛出以下错误

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.

如果我(同时 root 的 $PATH 中也有 /snap/bin)切换到超级用户,它也可以工作

sudo -i
然后运行任何 certbot 命令

请注意,我使用的是 debian 10,并使用

snapd 作为包管理器 根据教程 https://certbot.eff.org/lets-encrypt/snap-nginx

正如这里所解释的

https://unix.stackexchange.com/questions/245772/why-running-command-as-sudo-returns-command-not-found这是一种预期和认可的行为:

sudo 在执行外部命令时尝试确保安全。通常 解决方法是指定程序的完整路径名。它是 也更安全;如果你不指定路径,可以想象 攻击者可以创建另一个以 root 身份运行的程序 权限。

继续阅读,我可以看到我的路径是不同的

env | grep ^PATH sudo env | grep ^PATH
线程中提供了多种解决方案(使用自定义 sudo 或更改 sudo $PATH)

使用 sudo 时未找到命令,因此不必指定完整路径。


1
投票
尝试使用 snap 来删除


sudo snap remove certbot


然后再次安装

sudo snap install --classic certbot


    


0
投票
您可以尝试

让我们使用Certbot

Let's Certbot 是一个基于 Certbot 构建自动化脚本的工具,用于获取、续订、部署 SSL 证书。

支持docker和非docker环境。

GitHub:

https://github.com/jinhucheung/letscertbot


0
投票
试试这个 sudo ~/.certbot/bin/certbot certonly --webroot

© www.soinside.com 2019 - 2024. All rights reserved.