diff --git a/docs/tech/Commands-for-Server-Operation-and-Maintenance.md b/docs/tech/Commands-for-Server-Operation-and-Maintenance.md index 8942b42..b1787ef 100644 --- a/docs/tech/Commands-for-Server-Operation-and-Maintenance.md +++ b/docs/tech/Commands-for-Server-Operation-and-Maintenance.md @@ -4,7 +4,7 @@ ### Maria -**配置 GitHub 私钥**: +**推送 GitHub 私钥**: ```bash # 在 CatTomServer1 处执行 @@ -42,6 +42,17 @@ cd maria/script && chmod +x *.sh && ./maria.sh ### HomeLab +**推送 Gitea 私钥**: + +```bash +# 在 CatTomServer1 处执行 +rsync -avP /home/cattom/.ssh/cattom-gitea [server_id]:/home/cattom/.ssh/ +# 指定用户名与 IP +rsync -avP /home/cattom/.ssh/cattom-gitea root@[server_ip]:/home/cattom/.ssh/ +# 指定端口、私钥、用户名和 IP +rsync -avP -e 'ssh -p 25800 -i /home/cattom/.ssh/CatTomServer' /home/cattom/.ssh/cattom-gitea root@[server_ip]:/home/cattom/.ssh/ +``` + **编辑 SSH 客户端配置**: ```bash diff --git a/docs/tech/Creating-and-Managing-SSH-Keys-for-Authentication-on-Linux-Servers.md b/docs/tech/Creating-and-Managing-SSH-Keys-for-Authentication-on-Linux-Servers.md index cefabe3..764d984 100644 --- a/docs/tech/Creating-and-Managing-SSH-Keys-for-Authentication-on-Linux-Servers.md +++ b/docs/tech/Creating-and-Managing-SSH-Keys-for-Authentication-on-Linux-Servers.md @@ -4,13 +4,7 @@ 以下 `ssh-keygen` 命令默认在 `~/.ssh` 目录中生成 4096 位 SSH RSA 公钥和私钥文件。如果当前位置存在 SSH 密钥对,这些文件将被覆盖。 ``` bash -ssh-keygen \ - -m PEM \ - -t rsa \ - -b 4096 \ - -C "ubuntu@" \ - -f ~/.ssh/myprivatekey \ - -N mypassphrase +ssh-keygen -m PEM -t rsa -b 4096 -C "ubuntu@" -f ~/.ssh/myprivatekey -N mypassphrase ``` ### 命令解释 diff --git a/docs/tech/Picokeys.md b/docs/tech/Picokeys.md new file mode 100644 index 0000000..36217c2 --- /dev/null +++ b/docs/tech/Picokeys.md @@ -0,0 +1,100 @@ +# PicoKeys: YubiKey 的开源平替 + +!!! danger "重要提醒" + + 近期原作者[对固件代码增加了防回滚等功能](https://linux.do/t/topic/1469991),并且[将Pico Commissioner转入闭源](https://github.com/polhenarejos/pico-fido/issues/216),导致社区产生对原作者行为合理性的[质疑](https://github.com/polhenarejos/pico-fido/issues/245)。有鉴于此,社区已经产生基于原项目的[完全开源分支](https://github.com/librekeys/),但是该分支仍处于不稳定状态,分支的整体结构、更新方向和兼容性问题尚未有明确定论。**无论选择哪个固件,我强烈建议不要将刷入该固件的硬件密钥作为你保存 TOTP 和 Webauthn 密钥的唯一途径,并且妥善保管网站提供的恢复代码。** + +[Pico Keys](https://www.picokeys.com/) + +## 材料 + +- [微雪 RP2350-One](https://www.waveshare.net/wiki/RP2350-One) + +建议使用官方附赠贴纸粘贴在背面Logo处以紧固USB接口 + +## 安装 + +[Getting Started - Pico Keys](https://www.picokeys.com/getting-started/) + +Pico Fido + +Raspberry + +Pico 2 + +For Raspberry Pico, put the Pico device into recovery mode: + +- Unplug the device +- While pressing the BOOTSEL button, plug the device to the USB port +- A mounted flash unit will appear in the File Explorer / Finder named RP2350 (for RP2350 boards) +- Copy the .uf2 file download previously and copy to the mounted unit +- The device will unmount the flash unit and will be remounted as a Pico Key. The led light will blink periodically + +## 初始化 + +++windows+i++ 账户 登录选项 安全密钥 管理 + +插入 Picokey + +添加安全密钥 PIN + +## 配置 + +[picoforge](https://github.com/librekeys/picoforge) + +以管理员身份运行 + +Configuration + +- Identify + - Vendor Preset `Yubikey 5` + - Product Name `Yubico YubiKey` +- LED Setting + - LED GPIO Pin `16` + - LED Driver `WS2812` + - Brightness `5` + - LED Dimmable `Switch ON` +- Touch Timing + - Touch Timeouts `15` +- Device Options + - Power Cycle on Reset `Switch ON` + +Apply Changes + +按下开发板上的"Reset" + +## 使用 + +[Yubico Authenticator App for Desktop and Mobile | Yubico](https://www.yubico.com/products/yubico-authenticator/) + +添加 TOTP + +管理 通行密钥 + +- 蓝灯: 设备待机 +- 红灯: 设备处理中 +- 绿灯: 需要用户按 `BOOT` 键以授权 + +``` bash +ssh-keygen -t ed25519-sk -O resident -O verify-required -O application=ssh:custom_name -O user=my_username +``` + +https://zhuanlan.zhihu.com/p/691575345 + +## 其他 + +如何正确地擦除并刷写新固件? +在进行任何操作前,你需要先让 ESP32-S3 进入下载模式(Download Mode / DFU): +按住板子上的 BOOT(或 0)按钮不放。 +单击一下 RESET(或 EN / RST)按钮。 +松开 BOOT 按钮。 +(此时电脑会重新识别到一个串口设备) +接下来,根据你使用的刷写工具,选择对应的擦除方式: +方法一:使用命令行工具 esptool.py(最推荐、最彻底) +如果你熟悉命令行,使用乐鑫官方的 esptool 是最稳妥的。在终端中执行以下命令彻底清空闪存: + +``` powershell +esptool.py --chip esp32s3 --port COM3 erase_flash +``` + +显示 Flash memory erased successfully 后,你就可以像对待一块全新的 ESP32-S3 一样,用常规方法刷写任何其他固件了。 \ No newline at end of file diff --git a/docs/tech/Snippets.md b/docs/tech/Snippets.md new file mode 100644 index 0000000..fa37535 --- /dev/null +++ b/docs/tech/Snippets.md @@ -0,0 +1,55 @@ +# 专治各类疑难杂症 + +## Gitea 提示“找不到对应签名的密钥” + +仅仅将 SSH 密钥添加到 Gitea 还不够,为了防止他人伪造你的公钥,Gitea 要求你手动验证该密钥的所有权。 + +在你的 SSH / GPG 密钥 列表中,找到刚添加的密钥,点击旁边的验证按钮。 + +Gitea 会弹出一个带有随机 Token 的提示框,并要求你执行一条类似如下的命令: + +``` bash +echo -n 'gitea-xxxxxxxxxx' | ssh-keygen -Y sign -n gitea -f /path_to_your_privkey +``` + +!!! warning "Windows 11 用户避坑警告" + + 千万不要在 Windows 默认的 CMD 或 PowerShell 中执行这段命令! + + Windows 的 echo 命令不支持 -n 参数,它会把 -n 甚至回车换行符一起发送给硬件密钥进行签名。这会导致生成的签名数据完全错乱,提交到 Gitea 时会永远报错“签名不匹配”。 + +正确操作是在 Windows 11 中打开 Git Bash。 + +复制 Gitea 提供的命令并在 Git Bash 中执行。将 `/path_to_your_privkey` 替换为你本地密钥路径。(如果读取私钥存根失败,对于硬件密钥也可以尝试指向公钥) + +终端会输出一段被 -----BEGIN SSH SIGNATURE----- 和 -----END SSH SIGNATURE----- 包裹的签名块。 + +将这整段签名块复制,粘贴回 Gitea 的网页验证框中,点击确认即可。 + +## Material for MkDocs 粗体无法正常渲染 + +在 Material for MkDocs 中,出现**粗体**无法正常渲染的问题,通常是因为 Markdown 解析器依赖空格或特定的英文单词边界来识别强调语法的起止。 + +当 `**` 直接与中文字符紧凑相连,或紧贴括号、冒号等标点符号时,解析器会将其误认为是一段普通文本的内部字符,从而放弃渲染。 + +针对这个问题,可通过开启并配置 betterem 扩展解决。 + +打开项目的 `mkdocs.yml` 配置文件,找到 `markdown_extensions` 节点,添加 `pymdownx.betterem` 并开启全量智能匹配。 + +``` yaml title="mkdocs.yml" +markdown_extensions: + - pymdownx.betterem: + smart_enable: all +``` + +配置保存后,MkDocs 重新构建,绝大部分中文字母混排和括号内的加粗问题都会自动恢复正常。 + +如果上述方案不能解决问题,可能是 `smart_enable: all` 弄巧成拙。在 `betterem` 扩展的设计中,“智能(Smart)”这个词的实际含义是:“忽略词内强调(mid-word emphasis)”,即强制要求强调符号 `**` 前后必须有英文空格或单词边界。由于中文汉字之间没有空格,在解析器看来,整句中文是一个连贯的“长单词”。如果设置了 `smart_enable: all`,解析器会把 `**` 也变成“智能”模式,认为它插在“词内”,从而彻底拒绝渲染相连的中文加粗。 + +解决方案是将 `**` 恢复为“非智能(允许词内强调)”模式。关闭全量智能模式,只保留对下划线 `_` 的智能限制(这是官方默认且最适合中文混合排版的设置)。 + +``` yaml title="mkdocs.yml" +markdown_extensions: + - pymdownx.betterem: + smart_enable: '_' +``` \ No newline at end of file diff --git a/mkdocs.yml b/mkdocs.yml index 2daa41a..7525338 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -91,6 +91,7 @@ nav: - "原发免疫性血小板减少症 (ITP)": life/ITP.md - "技术": - tech/index.md + - "专治各类疑难杂症": tech/Snippets.md - "Mi 6 (sagit)": tech/Mi6(sagit).md - "极1S (HC5661)": tech/HC5661.md - "小米 CR6608": tech/CR6608.md