Skip to content

Conversation

jefferyjob
Copy link
Owner

大多数开发者在使用 curl 下载和运行脚本时,通常会遵循以下方式以保证稳定性和安全性:

  1. 下载脚本:通过 curl 下载脚本文件时,常用参数组合为 -fsSL。这几个参数的含义是:

    • -f:将非 2xx/3xx 的 HTTP 响应视为错误。
    • -s:禁止显示进度条。
    • -S:在发生错误时显示错误信息(与 -s 搭配使用)。
    • -L:自动跟随重定向。
    • -o [filename]: 将下载的内容保存到指定文件。

    示例:

    curl -fsSLo deploy.notice.sh https://raw.githubusercontent.com/jefferyjob/deployments/refs/heads/main/scripts/deploy.docker.sh
  2. 运行脚本:下载后,直接使用 bashsh 来运行脚本。为了保证下载成功,可以将下载和执行合并到一行命令中:

    curl -fsSL https://raw.githubusercontent.com/jefferyjob/deployments/refs/heads/main/scripts/deploy.docker.sh | bash  -s -- <AUTH_METHOD> <ACTION>

这种方式是大多数开发者推荐的通用做法,确保了脚本下载的安全性和简洁性。

如果需要进一步确保下载的脚本没有被篡改,可以考虑为脚本附加哈希值验证,或者使用 HTTPS 协议来下载。

@jefferyjob jefferyjob added the feature New feature or request label Oct 8, 2024
@jefferyjob jefferyjob merged commit 6262897 into main Oct 8, 2024
1 check passed
@jefferyjob jefferyjob deleted the feature/1008_curd branch October 8, 2024 04:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant