設定

設定

SSH-Frontièreは、ドメイン、アクション、アクセスレベル、引数、認証トークンを宣言するためにTOMLファイルを使用します。

ファイルの場所

デフォルトパス/etc/ssh-frontiere/config.toml

上書き(優先順位順):

  1. authorized_keyscommand=行での--config <path>
  2. 環境変数SSH_FRONTIERE_CONFIG
  3. デフォルトパス

推奨パーミッションroot:forge-runner 640(サービスアカウントに合わせてグループを調整してください)。

ファイル構造

[global]                              # 全般設定
[domains.<id>]                        # 機能ドメイン
  [domains.<id>.actions.<id>]         # 許可されたアクション
    [domains.<id>.actions.<id>.args]  # 名前付き引数(任意)
[auth]                                # RBAC認証(任意)
  [auth.tokens.<id>]                  # シークレット、レベル、タグを持つトークン

[global]セクション

キーデフォルト説明
log_filestring必須JSONログファイルのパス
default_timeoutinteger300デフォルトのタイムアウト(秒)
max_stdout_charsinteger65536stdout制限(64 KB)
max_stderr_charsinteger16384stderr制限(16 KB)
max_output_charsinteger131072グローバルハード制限(128 KB)
max_stream_bytesinteger10485760ストリーミング量制限(10 MB)
timeout_sessioninteger3600セッションkeepaliveタイムアウト
max_auth_failuresinteger3ロックアウトまでの認証試行回数
ban_commandstring""IPバンコマンド(プレースホルダ{ip}
log_commentsboolfalseクライアントの#行をログに記録
expose_session_idboolfalseバナーにセッションUUIDを表示

log_leveldefault_levelmask_sensitiveキーは、古い設定との後方互換性のためにパーサーで受け入れられますが、現在は使用されていません。

[domains]セクション

ドメインは機能的なスコープです(例:forgejoinfranotify)。各ドメインには許可されたアクションが含まれます。

[domains.forgejo]
description = "Git forge infrastructure"

[domains.forgejo.actions.backup-config]
description = "Backup the configuration"
level = "ops"
timeout = 600
execute = "sudo /usr/local/bin/backup-config.sh {domain}"
max_body_size = 65536       # ボディ制限(64 KB、任意)

各アクションは以下のキーを受け付けます:description(必須)、level(必須)、execute(必須)、timeout(任意、グローバルを上書き)、tags(任意)、max_body_size(任意、デフォルト65536バイト — +bodyプロトコル用に制限)。

信頼レベル

厳密な階層:read < ops < admin

レベル用途
read読み取り専用:healthcheck、status、list
ops定常運用:backup、deploy、restart
adminすべてのアクション+管理

引数

引数はTOML辞書として宣言します:

[domains.forgejo.actions.deploy.args]
tag = { type = "enum", values = ["latest", "stable", "canary"], default = "latest" }
フィールド説明
typestring"enum"または"string"
valueslist許可された値(enum用)
defaultstringデフォルト値(引数を任意にする)
sensitivebooltrueの場合、ログでマスキング
freebooltrueの場合、制約なしで任意の値を受け入れ

execute内のプレースホルダ

プレースホルダ説明
{domain}ドメイン名(常に利用可能)
{arg_name}対応する引数の値

可視性タグ

タグはアクションへのアクセスを水平的にフィルタリングします。タグのないアクションはすべてのユーザーがアクセスできます。タグのあるアクションは、少なくとも1つのタグを共有するアイデンティティのみがアクセスできます。

[domains.forgejo.actions.deploy]
# ...
tags = ["forgejo", "deploy"]

[auth]セクション(任意)

RBAC認証は、チャレンジ・レスポンスによる権限昇格を可能にします:

[auth]
challenge_nonce = false              # true = アンチリプレイノンスモード

[auth.tokens.runner-ci]
secret = "b64:c2VjcmV0LXJ1bm5lci1jaQ=="   # Base64エンコードされたシークレット
level = "ops"                               # 付与されるレベル
tags = ["forgejo"]                          # 可視性タグ

シークレットにはb64:プレフィックスを付け、Base64でエンコードする必要があります。シークレットの生成方法:

echo -n "my-random-secret" | base64
# bXktcmFuZG9tLXNlY3JldA==

読み込み時の検証

設定は各読み込み時に完全に検証されます(フェイルファスト)。エラー時にはプログラムがコード129で終了します。検証内容:

完全な例

[global]
log_file = "/var/log/ssh-frontiere/commands.json"
default_timeout = 300
max_stdout_chars = 65536
max_stderr_chars = 16384
max_output_chars = 131072
timeout_session = 3600
max_auth_failures = 3

[domains.forgejo]
description = "Git forge infrastructure"

[domains.forgejo.actions.backup-config]
description = "Backup the Forgejo configuration"
level = "ops"
timeout = 600
execute = "sudo /usr/local/bin/backup-config.sh {domain}"

[domains.forgejo.actions.deploy]
description = "Deployment with version tag"
level = "ops"
timeout = 300
execute = "sudo /usr/local/bin/deploy.sh {domain} {tag}"

[domains.forgejo.actions.deploy.args]
tag = { type = "enum", values = ["latest", "stable", "canary"], default = "latest" }

[domains.infra]
description = "Server infrastructure"

[domains.infra.actions.healthcheck]
description = "Service health check"
level = "read"
timeout = 30
execute = "/usr/local/bin/healthcheck.sh"

[auth]
challenge_nonce = false

[auth.tokens.runner-ci]
secret = "b64:c2VjcmV0LXJ1bm5lci1jaQ=="
level = "ops"
tags = ["forgejo"]

すべてのユースケースを網羅した詳細なガイドについては、リポジトリ内の完全な設定ガイドを参照してください。


次へデプロイ — 本番環境へのデプロイ。