Skip to content

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_KEY env — 본인 ainote primary UserMcpKey 또는 User.api_key

선택:

  • $AINOTE_API_BASE env — 기본 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}

bash
# 첫 발급
ainote-cert-mirror issue

# hmac_secret 분실 시
ainote-cert-mirror issue --rotate

list

본인 blob 목록 (최신순, 최대 20). JSON 출력.

서버 호출: GET /api/cert_mirror

bash
ainote-cert-mirror list
json
{
  "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 검증용.

bash
ainote-cert-mirror latest
json
{
  "commit_sha": "268112ce…",
  "byte_size": 60781,
  "uploaded_at": "2026-05-16T23:16:43.855Z"
}

빈 상태:

json
{ "blobs": [] }

verify

엔드포인트 200 + Keychain entry 존재 + blob 카운트 확인. 헬스체크용.

bash
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. 디버깅용.

bash
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

bash
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)

수동 조회:

bash
security find-generic-password -s "ainote mirror token" -w
security find-generic-password -s "ainote mirror hmac"  -w

수동 등록 (다른 mac 에서 복사 시):

bash
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 setenv 누락 (혹은 subshell 에서 안 보임)~/.zshrc export 후 source ~/.zshrc
Unexpected server response서버가 새 status 코드 반환서버 배포 확인, 필요 시 스크립트 업데이트
issueexisting 반환했는데 Keychain hmac 없음이전 mac 에서 발급 → 현재 mac 으로 hmac 미동기화iCloud Keychain 확인 후 안 되면 issue --rotate
verify 의 endpoint HTTP 401UserMirrorCredential 이 삭제됨 (다른 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_BASEhttps://api.ainote.devself-host 시 override

(AINOTE_MIRROR_TOKEN, AINOTE_MIRROR_HMAC_SECRET 같은 mirror-side env 는 fastlane 워크플로우에서 따로 export — 스크립트는 Keychain 우선)

다음