Persona CLI Guide (Integrated with DOB CLI)

The persona CLI, in collaboration with the dob CLI, provides a robust Role-Based Access Control (RBAC) system for remote command execution and configuration management. This guide details its usage, focusing on commands, configurations, and integration workflows.

1. persona config

Description: Configure the remote execution environment by generating a .dobconfig.json file.

Usage:

persona config --persona-name <persona_name> --token <token> \
              --private-key-path <private_key_path> --host-endpoint <host_endpoint>

Options:

Details:

  1. Creates a configuration file at ~/.dobconfig.json.
  2. Stores persona information, token, private key path, and host endpoint for seamless remote command execution.

Example:

persona config --persona-name admin --token abc123 \
              --private-key-path ~/keys/admin_key.pem --host-endpoint http://127.0.0.1:8080

Output:

2. persona run

Description: Proxy any dob command to the host for execution.

Usage:

persona run <dob_command> [--file-path <path_to_file>]

Options:

Details:

  1. Loads configuration from ~/.dobconfig.json.
  2. Signs the token using the specified private key.
  3. Sends the command and optional file content to the host endpoint for execution.
  4. Outputs the execution result.

Example:

persona run create-cluster --region us-east-1 --file-path config.yaml

Output:

Error Handling:

Configuration File (~/.dobconfig.json)

The configuration file contains the following keys:


{
    "persona_name": "<persona_name>",
    "token": "<token>",
    "private_key_path": "<path_to_private_key>",
    "host_endpoint": "<host_endpoint_url>"
}
      

Example:


{
    "persona_name": "admin",
    "token": "abc123",
    "private_key_path": "/home/user/keys/admin_key.pem",
    "host_endpoint": "http://127.0.0.1:8080"
}
      

Token Signing

The persona CLI uses RSA key pairs to sign tokens for secure communication. The private key specified in the configuration is used to generate a signature.

Function:


def sign_token(private_key_path, token):
    with open(private_key_path, "rb") as key_file:
        private_key = serialization.load_pem_private_key(key_file.read(), password=None)

    signature = private_key.sign(
        token.encode(),
        padding.PKCS1v15(),
        hashes.SHA256()
    )

    return signature.hex()
      

Details:

Example Workflow

  1. Configure Persona:
  2. persona config --persona-name admin --token abc123 \
                     --private-key-path ~/keys/admin_key.pem --host-endpoint http://127.0.0.1:8080
  3. Run a Command:
  4. persona run create-cluster --region us-east-1 --file-path cluster.yaml
  5. Host Execution:
  6. The command is forwarded to the host endpoint (http://127.0.0.1:8080/execute). The host validates the signature and token before executing the command.

  7. View Results:
  8. The persona CLI outputs the result from the host.

Error Handling

Security Considerations

This guide ensures you can utilize the persona CLI effectively for secure and controlled remote command execution with dob. For additional support, consult the documentation or contact your system administrator.