PR Check / Security scan (Snyk) (pull_request) Skipped
PR Check / Lint + typecheck (pull_request) Failing after 19s
PR Check / Secret scan (gitleaks) (pull_request) Successful in 6s
PR Check / Dependency audit (pull_request) Failing after 9s
PR Check / Dockerfile lint (droast) (pull_request) Successful in 5s
57 lines
1.8 KiB
Bash
Executable File
57 lines
1.8 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Final step: remove the agent's inherited noel access.
|
|
#
|
|
# Run on server0 only after the agent command works:
|
|
# ssh -i ~/.ssh/pr_agent_control -o IdentitiesOnly=yes agent@91.99.207.62 status
|
|
#
|
|
# This removes noel from docker and sudo, clears noel's authorized_keys,
|
|
# and deletes the old PR-Agent directory that held the secrets. Make sure
|
|
# you have another admin path (provider console or a new key) first.
|
|
|
|
set -euo pipefail
|
|
|
|
if [ "$(id -u)" -ne 0 ]; then
|
|
echo "run as root" >&2
|
|
exit 1
|
|
fi
|
|
|
|
cat <<'EOF'
|
|
This will:
|
|
- remove noel from the docker and sudo groups
|
|
- clear every key in /home/noel/.ssh/authorized_keys
|
|
- delete /home/noel/self-hosted/pr-agent (the /opt copy remains)
|
|
Existing noel SSH sessions keep their old groups until they log out.
|
|
Make sure you have another admin path before continuing.
|
|
EOF
|
|
read -r -p "Type REMOVE to continue: " answer
|
|
[ "$answer" = "REMOVE" ] || { echo "aborted"; exit 1; }
|
|
|
|
if id -nG noel | tr ' ' '\n' | grep -qx docker; then
|
|
gpasswd -d noel docker
|
|
fi
|
|
if id -nG noel | tr ' ' '\n' | grep -qx sudo; then
|
|
deluser noel sudo
|
|
fi
|
|
|
|
if [ -f /home/noel/.ssh/authorized_keys ]; then
|
|
cp -a /home/noel/.ssh/authorized_keys \
|
|
"/root/noel-authorized_keys.$(date +%Y%m%d-%H%M%S).bak"
|
|
: > /home/noel/.ssh/authorized_keys
|
|
chown noel:noel /home/noel/.ssh/authorized_keys
|
|
chmod 600 /home/noel/.ssh/authorized_keys
|
|
fi
|
|
|
|
rm -rf /home/noel/self-hosted/pr-agent
|
|
|
|
cat <<'EOF'
|
|
|
|
Done. Test the restricted path again:
|
|
|
|
ssh -i ~/.ssh/pr_agent_control -o IdentitiesOnly=yes agent@91.99.207.62 status
|
|
|
|
Still to do outside this script:
|
|
- remove the old personal SSH key from Gitea (Settings > SSH / GPG Keys)
|
|
- add ~/.ssh/pr_agent_gitea.pub as a write deploy key on CV_Site_Nuxt
|
|
- put the OpenCode Go key in /opt/pr-agent/.env and run the deploy helper
|
|
EOF
|