ainote-cert-mirror — CLI 레퍼런스
macOS 용 zsh 스크립트. cert mirror credential 관리 + endpoint 호출 + Keychain 통합을 한 줄로 묶음.
처음 셋업하는 경우 setup-guide 부터.
설치
스크립트 본문은 GitHub 또는 본인 mac 의 ~/scripts/ainote-cert-mirror.sh. PATH 에 ~/scripts 추가 권장.
의존성
- zsh (macOS 기본)
curl(macOS 기본)python3(macOS 기본 — JSON 파싱)security(macOS 기본 — Keychain)$AINOTE_API_KEYenv — 본인 ainote primary UserMcpKey 또는 User.api_key
선택:
$AINOTE_API_BASEenv — 기본https://api.ainote.dev. 자기 호스트 ainote_server 운영 중이면 override
⚠️ 계정 매칭 주의
AINOTE_API_KEY 환경변수가 가리키는 ainote 계정 = UserMirrorCredential 이 만들어질 계정입니다. 여러 계정 (예: 메일별 분리) 보유 시 잘못된 키로 issue 하면 다른 계정에 새 credential 이 만들어집니다 — 기존 계정의 cert mirror 와 무관한 빈 mirror 가 생성되는 함정.
조치:
ainote-cert-mirror show로 env 의 키 길이만 우선 확인- 미심쩍으면
issue전에list호출 — token 이 다른 계정 것이면unauthorized또는 빈 blob 응답 - 실수로 만들었으면
revoke로 즉시 정리 (blob 0개 상태면 부수효과 없음)
Subcommands
issue [--rotate]
UserMirrorCredential 발급 / 갱신. 결과 token + hmac_secret 을 Keychain 에 저장.
| 옵션 | 동작 |
|---|---|
| (없음) | 기존 credential 있으면 token 만 Keychain 동기화 (hmac 은 못 받음). 없으면 신규 발급 |
--rotate | 기존 destroy + 신규 생성. token + hmac 모두 새로 받음. ⚠️ 기존 blob 들은 HMAC 검증 실패 |
서버 호출: POST /api/cert_mirror/credentials body {"rotate": true/false}
# 첫 발급
ainote-cert-mirror issue
# hmac_secret 분실 시
ainote-cert-mirror issue --rotatelist
본인 blob 목록 (최신순, 최대 20). JSON 출력.
서버 호출: GET /api/cert_mirror
ainote-cert-mirror list{
"blobs": [
{
"commit_sha": "268112ce…",
"sha256": "53c9b81e…",
"byte_size": 60781,
"uploaded_at": "2026-05-16T23:16:43.855Z",
"uploaded_by": "fastlane:seunghan"
}
]
}latest
가장 최근 blob 1개 메타데이터. heartbeat / CI 검증용.
ainote-cert-mirror latest{
"commit_sha": "268112ce…",
"byte_size": 60781,
"uploaded_at": "2026-05-16T23:16:43.855Z"
}빈 상태:
{ "blobs": [] }verify
엔드포인트 200 + Keychain entry 존재 + blob 카운트 확인. 헬스체크용.
ainote-cert-mirror verify✅ Endpoint https://api.ainote.dev/api/cert_mirror reachable (200)
✅ Keychain: token (64 chars) + hmac (64 chars) present
✅ Blobs uploaded: 1실패 시 exit code 1 — CI 에서 그대로 활용 가능.
show
Keychain entry 길이 + env 상태만 표시. 값은 노출 X. 디버깅용.
ainote-cert-mirror showℹ️ token: 64 chars (service: "ainote mirror token")
ℹ️ hmac: 64 chars (service: "ainote mirror hmac")
ℹ️ API base: https://api.ainote.dev
ℹ️ AINOTE_API_KEY env: set (64 chars)revoke
서버 credential destroy + Keychain entry 2개 삭제. 확인 prompt.
서버 호출: DELETE /api/cert_mirror/credentials
ainote-cert-mirror revoke
# ⚠️ Destroy your UserMirrorCredential? Previously uploaded blobs become unreachable. [y/N] y기존 blob 들은 서버 디스크에 남지만 새 credential 발급 + 재업로드 전까지 다운로드 불가 (HMAC secret 분실).
help (또는 -h, --help)
usage 출력.
Keychain entry 이름
스크립트가 사용하는 service:
ainote mirror token— UserMirrorCredential.token (64 hex)ainote mirror hmac— UserMirrorCredential.hmac_secret (64 hex)
수동 조회:
security find-generic-password -s "ainote mirror token" -w
security find-generic-password -s "ainote mirror hmac" -w수동 등록 (다른 mac 에서 복사 시):
security add-generic-password -s "ainote mirror token" -a "$USER" -w '<value>'Linux / CI 환경
스크립트는 macOS Keychain 의존. Linux/Docker/GitHub Actions 등은 api 페이지 의 curl 패턴 + 환경변수 (AINOTE_MIRROR_TOKEN, AINOTE_MIRROR_HMAC_SECRET) 직접 사용 권장.
함정
| 증상 | 원인 | 해결 |
|---|---|---|
AINOTE_API_KEY ... not set | env 누락 (혹은 subshell 에서 안 보임) | ~/.zshrc export 후 source ~/.zshrc |
Unexpected server response | 서버가 새 status 코드 반환 | 서버 배포 확인, 필요 시 스크립트 업데이트 |
issue 가 existing 반환했는데 Keychain hmac 없음 | 이전 mac 에서 발급 → 현재 mac 으로 hmac 미동기화 | iCloud Keychain 확인 후 안 되면 issue --rotate |
verify 의 endpoint HTTP 401 | UserMirrorCredential 이 삭제됨 (다른 mac 에서 revoke?) | issue 다시 (기존 token 회수) 또는 --rotate |
| 스크립트 자체 zsh 문법 오류 | bash 로 실행 시도 | shebang #!/bin/zsh 명시 + zsh ainote-cert-mirror.sh |
환경변수 정리
| 변수 | 필수 | 기본 | 용도 |
|---|---|---|---|
AINOTE_API_KEY | ✅ (issue/revoke 시) | — | UserMcpKey, primary auth |
AINOTE_API_BASE | https://api.ainote.dev | self-host 시 override |
(AINOTE_MIRROR_TOKEN, AINOTE_MIRROR_HMAC_SECRET 같은 mirror-side env 는 fastlane 워크플로우에서 따로 export — 스크립트는 Keychain 우선)