跳到主要内容

5.2.7. Key Constraints

Constraints 作为 type bytes 加 constraint-specific data 追加到 constrained add-key requests. 如果 agent 不识别或不支持 requested constraint, 它 MUST abort parsing, refuse the request, 并向 client 返回 SSH_AGENT_FAILURE.

已定义 constraints 包括带 uint32 seconds 值的 SSH_AGENT_CONSTRAIN_LIFETIME, SSH_AGENT_CONSTRAIN_CONFIRM, 以及带 extension name 和 extension-specific details 的 SSH_AGENT_CONSTRAIN_EXTENSION. Vendor extension names MUST 遵循 [RFC4251] 的 domain-qualified naming scheme, 例如 [email protected].

Key constraints 用于限制 agent 中 key 的使用方式. Lifetime constraint 限制 key 在 agent 中可用的时间, confirm constraint 要求每次使用前进行确认, extension constraint 则为未来或厂商特定约束提供扩展点. 这些约束会影响私钥使用权限, 因此 agent 必须在解析 add-key request 时严格验证约束格式.

如果 agent 忽略未知约束而继续添加 key, client 可能误以为 key 已受到限制, 实际却可被无限制使用. 因此, 本节要求不识别或不支持约束时返回 failure, 这是保护 SSH agent 安全语义的关键规则.