适用场景:每台服务器上都有完整项目;你会先手动 push 一次,并用
git config --global credential.helper store保存凭据;之后 systemd 服务无交互自动 pushruntime-state。
可以,按你的逻辑完全可行:
credential.helper storegit push 一次(触发输入用户名/密码或 Token)不需要 --git-http-token-file。
假设项目目录为 /home/aurora/vmess-domain-rotator,远端为 origin。
cd /home/aurora/vmess-domain-rotator
git remote get-url origin
必须是 https://...,例如:
https://git.example.com/aurora/vmess-domain-rotator.git
如果是 SSH 地址(
git@...),就不是 credential store 这套流程。
git config --global credential.helper store
你可以 push 任意分支(同一个 HTTPS 主机即可),例如:
git push origin main
首次会提示输入用户名与密码(或 Token),输入后会写入 ~/.git-credentials。
sudo bash scripts/install_debian.sh \
--interval 1h \
--git-push 1 \
--git-use-credential-store 1
默认会使用当前
sudo执行者作为服务用户(即SUDO_USER)。
sudo systemctl start vmess-domain-rotator.service
sudo journalctl -u vmess-domain-rotator.service -n 120 --no-pager
日志应看到:
committed domain change on runtime-state ...pushed to origin/runtime-staterun_update_and_commit.sh 在服务里是无交互执行(GIT_TERMINAL_PROMPT=0)。credential.helper store + 曾成功 push),后续 push 不需要再交互。每台服务器都重复同样流程(凭据不会跨机器同步):
git config --global credential.helper storegit push 一次保存凭据install_debian.sh --git-push 1 --git-use-credential-store 1即:一机一初始化。
aurora 手动保存的凭据,但服务跑在别的用户下,就读不到。credential.helper store 对 SSH remote 不生效。~/.git-credentials 为明文,请确保服务器权限可控。