diff --git a/README.md b/README.md index 7ad5e2b..3763452 100644 --- a/README.md +++ b/README.md @@ -4,9 +4,54 @@ Quickly install SSH into the server. ## Usage 执行命令: ```bash -curl -s https://lamgc.github.io/quickly-conf-sshd/conf-sshd.sh | bash -s -- -c +curl -s https://ssh.lamgc.me | bash -s -- -c ``` 如果不希望自动更新密钥,可以执行: ```bash -curl -s https://lamgc.github.io/quickly-conf-sshd/conf-sshd.sh | bash -s -``` \ No newline at end of file +curl -s https://ssh.lamgc.me | bash -s +``` + +## Install +### Configuration +先 Fork 本仓库,Fork 后在仓库设置中启用 Github Pages,分支指向 main 分支,目录为仓库根目录。 +配置好后将仓库克隆到本地,然后修改 `cf-worker/src/index.js` 中的前五个变量: +```javascript +// 改成你自己的 Github 用户名,注意是登录 Github 的那个用户名. +const githubUserName = "LamGC"; +// 改成你 Fork 后的仓库名,记得要开启 Github Pages 功能. +const githubInstSshProjectName = "quickly-conf-sshd"; +// 如果可以,建议在此设置备用的 SSH 公钥, 以防 Github 无法使用. +const backupSshKeys = ``; +// Worker 的访问地址, 如果不填的话默认为请求的地址, 填了就会用这里的地址(要去 Worker 的触发器那绑定, 否则无效). +const defaultBaseUrl = ""; +// Cron 表达式, 默认 1 天执行一次更新. +const cronExpression = "0 0 * * *"; +``` + +### Use Wrangler +如果你安装了 Cloudflare 的 Wrangler,可以直接在 `cf-worker` 目录中执行: +```bash +wrangler publish +``` +执行后将会自动创建 Worker 并上传 worker js 代码,Worker 的名字是 `quickly-conf-ssh-worker`。 + +### Manual Install +如果你没有安装 Wrangler,那就手动在 Cloudflare Workers 中新建一个 Worker,名字你喜欢就好(也可以使用 `quickly-conf-ssh-worker`),选择 HTTP 处理程序,然后下一步; + +![Create a new worker](docs/Create-a-new-worker.png) + +创建完成后点击 Worker 名称右边的**快速编辑**,将 `cf-worker/src/index.js` 中的内容复制到编辑框中,把原本的代码覆盖掉,然后保存; +![Copy Code](docs/copy-js-code-to-worker.png) + +保存后需要访问一下 Worker,检查是否有误(如果不检查仔细,把其他人的 SSH 密钥设置到服务器里了,那就寄咯): +- 直接访问 Worker 地址,看看是否能跳转到你 Fork 的仓库中(地址栏显示了 `https://{你的 Github 用户名}.github.io/{Fork的仓库名}/`); +- 访问 `{Worker地址}/ssh.keys`,应该显示你的在 Github 设置了的所有 SSH 公钥,如果是空的或者不是你的密钥,那就检查一下是不是 Github 用户名填错了; +- 访问 `{Worker地址}/script.sh`,应该返回一个脚本,脚本开头的配置应与你在 Worker 开头的有关配置一致。 + +检查无误后就算安装完成了。 + +### (可选)使用自定义域名 +在 Worker 详情中,点击“触发器”,然后点击“添加自定义域”,按照提示输入已添加在 Cloudflare 中的域名即可。 +![Add Custom Domain](docs/add-custom-domain.png) +![Input Custom Domain](docs/input-custom-domain.png) +![Added Custom Domain](docs/added-custom-domain.png) diff --git a/docs/Create-a-new-worker.png b/docs/Create-a-new-worker.png new file mode 100644 index 0000000..b9aed41 Binary files /dev/null and b/docs/Create-a-new-worker.png differ diff --git a/docs/add-custom-domain.png b/docs/add-custom-domain.png new file mode 100644 index 0000000..bb5efac Binary files /dev/null and b/docs/add-custom-domain.png differ diff --git a/docs/added-custom-domain.png b/docs/added-custom-domain.png new file mode 100644 index 0000000..2a64cd6 Binary files /dev/null and b/docs/added-custom-domain.png differ diff --git a/docs/copy-js-code-to-worker.png b/docs/copy-js-code-to-worker.png new file mode 100644 index 0000000..94c0b02 Binary files /dev/null and b/docs/copy-js-code-to-worker.png differ diff --git a/docs/input-custom-domain.png b/docs/input-custom-domain.png new file mode 100644 index 0000000..33e4751 Binary files /dev/null and b/docs/input-custom-domain.png differ