Back to Infisical

infisical pam

docs/cli/commands/pam.mdx

0.162.06.0 KB
Original Source
bash
infisical pam access <path> [flags]

Description

The infisical pam command provides privileged access management capabilities for securely accessing databases, SSH servers, Kubernetes clusters, AWS IAM roles, and Windows/RDP servers through Infisical's Gateway.

All PAM commands require the user to be logged in via infisical login.

Command Structure

infisical pam
└── access <path>     # unified, path-based access to all PAM resources

infisical pam access

Access PAM-managed resources through Infisical's Gateway. This unified command handles all resource types — databases, SSH servers, Kubernetes clusters, AWS IAM roles, and Windows/RDP servers. The account type is determined by the template assigned to the account.

bash
infisical pam access <path> [flags]

Arguments

ArgumentDescription
<path>Required. Path to the PAM account in format folder/account-name

Flags

<Accordion title="--duration"> Session duration. Supports Go duration format (e.g., `1h`, `30m`, `2h30m`).

Default value: 1h

bash
# Example
infisical pam access production/postgres-main --duration 4h
</Accordion> <Accordion title="--reason"> Audit reason for access. Required by some policies; prompts interactively if TTY available.
bash
# Example
infisical pam access production/database --reason "Investigating incident INC-1234"
</Accordion> <Accordion title="--port"> Local proxy port. Use `0` for auto-assign.

Default value: 0

bash
# Example
infisical pam access staging/mysql-replica --port 3306
</Accordion> <Accordion title="--target"> Target host for multi-host accounts (e.g., Windows AD environments).
bash
# Example
infisical pam access windows/domain-admin --target dc01.corp.local
</Accordion> <Accordion title="--domain"> Domain of your self-hosted Infisical instance. If not specified, defaults to Infisical Cloud.
bash
# Example
infisical pam access production/database --domain https://your-infisical-instance.com
</Accordion>

Account Types and Behavior

Based on the account's template, the CLI starts the appropriate local proxy or credential helper.

Databases (PostgreSQL, MySQL, SQL Server, MongoDB)

Starts a local database proxy on 127.0.0.1. Connect using standard database clients — no password required as authentication is handled by the proxy.

bash
# Example
infisical pam access production/postgres-main --duration 2h

The output includes connection details and CLI examples:

Database TypeConnection String Format
PostgreSQLpostgres://<username>@127.0.0.1:<port>/<database>
MySQLmysql://<username>@127.0.0.1:<port>/<database>
SQL Serversqlserver://<username>@127.0.0.1:<port>?database=<database>
MongoDBmongodb://127.0.0.1:<port>/<database>

SSH

Starts a local SSH proxy. Use standard SSH/SCP/SFTP/rsync commands to connect.

bash
# Start the proxy
infisical pam access servers/prod-bastion

Then connect using your SSH client:

bash
# SSH
ssh -p <port> -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null [email protected]

# SCP file transfer
scp -P <port> -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null file.txt [email protected]:/path/

# rsync
rsync -e "ssh -p <port> -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" local-dir/ [email protected]:/remote/path/

Kubernetes

Starts a local Kubernetes proxy and automatically configures kubectl context.

bash
# Example
infisical pam access clusters/prod-cluster --duration 4h

kubectl is automatically configured with a context named infisical-k8s-pam/folder/account-name. Use kubectl normally:

bash
kubectl get pods
kubectl get namespaces

The original kubeconfig context is restored when the session ends.

AWS IAM

Writes temporary STS credentials to your AWS credentials file (~/.aws/credentials or wherever AWS_SHARED_CREDENTIALS_FILE points).

bash
# Example
infisical pam access aws/production-role

The credentials are written as a named profile: infisical-pam/folder/account-name

Use with the AWS CLI:

bash
# Use --profile flag
aws s3 ls --profile "infisical-pam/aws/production-role"

# Or export the profile
export AWS_PROFILE="infisical-pam/aws/production-role"
aws s3 ls

The session blocks until Ctrl+C or credential expiry. When the session ends, the profile is removed from the credentials file.

Windows / RDP

Starts a local RDP proxy. Connect your RDP client to 127.0.0.1 on the assigned port.

bash
# Single-server Windows account
infisical pam access windows/admin-server

# Windows AD with multiple targets
infisical pam access windows/domain-admin --target dc01.corp.local

Connect using your preferred RDP client (e.g., Microsoft Remote Desktop, xfreerdp, Remmina).

MFA Support

If your organization requires MFA for PAM access:

  1. CLI detects SESSION_MFA_REQUIRED response
  2. Browser opens to MFA verification page
  3. CLI polls for up to 5 minutes for completion
  4. Access continues automatically after MFA verification

Reason Prompting

Some PAM policies require an audit reason. Behavior:

ScenarioBehavior
With --reason flagUses provided reason
Interactive terminal (TTY)Prompts for reason if required
Non-interactive (CI/CD)Fails with error if reason required but not provided
bash
# Provide reason via flag
infisical pam access production/database --reason "Investigating incident INC-1234"

Error Messages

ErrorCauseSolution
Invalid duration formatMalformed --duration valueUse formats like 1h, 30m, 2h30m
a reason is required to access this accountPolicy requires reason, no TTYPass --reason flag
Gateway does not support '{type}' PAM accountsGateway version too oldUpgrade Infisical Gateway
PAM response metadata is missingAPI response incompleteContact support