By Fatskills Exam Guides Team — the exam nerds behind 28,500+ quizzes and 2.1M practice questions across 500+ global exams.
Privileged Access Management (PAM) is the set of tools and processes that control, monitor, and audit accounts with elevated permissions (e.g., admins, service accounts, root users). Just-in-Time (JIT) Access is a PAM strategy where privileges are granted only when needed and revoked immediately after use—like a temporary keycard for a server room.
chmod 777
rm -rf /
Real-world scenario: You’re a sysadmin at a healthcare company. A developer needs root access to a production database to debug a critical outage. Without PAM/JIT, you’d either:1. Give them permanent admin rights-Risk of misuse or credential theft.2. Manually SSH in and run commands for them-Bottleneck, slow response.3. Use JIT-Grant temporary, audited access that auto-revokes after 30 minutes.
This guide will show you how to implement PAM/JIT today—with real commands, configs, and best practices.
root
sudo
sa
Run as Administrator
systemctl restart nginx
ServiceAccount
aws configure
dev-user
Grant dev-user temporary admin access to an EC2 instance only when needed, with auto-revocation.
This policy allows dev-user to assume a role with admin rights only when approved.
# Create a JSON policy file (jit-admin-policy.json) cat > jit-admin-policy.json << 'EOF' { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": "sts:AssumeRole", "Resource": "arn:aws:iam::YOUR_ACCOUNT_ID:role/JIT-Admin-Role", "Condition": { "StringEquals": { "aws:RequestedRegion": "us-east-1" }, "NumericLessThanEquals": { "aws:MultiFactorAuthAge": "3600" # Require MFA within last hour } } } ] } EOF
Apply the policy:
aws iam create-policy --policy-name JIT-Admin-Policy --policy-document file://jit-admin-policy.json
This role has admin permissions but can only be assumed via the JIT policy.
# Create a trust policy (trust-policy.json) cat > trust-policy.json << 'EOF' { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": { "AWS": "arn:aws:iam::YOUR_ACCOUNT_ID:user/dev-user" }, "Action": "sts:AssumeRole", "Condition": { "Bool": { "aws:MultiFactorAuthPresent": "true" } } } ] } EOF # Create the role aws iam create-role --role-name JIT-Admin-Role --assume-role-policy-document file://trust-policy.json # Attach admin permissions to the role aws iam attach-role-policy --role-name JIT-Admin-Role --policy-arn arn:aws:iam::aws:policy/AdministratorAccess
aws iam attach-user-policy --user-name dev-user --policy-arn arn:aws:iam::YOUR_ACCOUNT_ID:policy/JIT-Admin-Policy
As dev-user, request temporary credentials:
# Get temporary credentials (valid for 1 hour) aws sts assume-role \ --role-arn arn:aws:iam::YOUR_ACCOUNT_ID:role/JIT-Admin-Role \ --role-session-name "JIT-Admin-Session" \ --duration-seconds 3600
Output:
{ "Credentials": { "AccessKeyId": "ASIA...", "SecretAccessKey": "...", "SessionToken": "...", "Expiration": "2024-01-01T12:00:00Z" } }
Export credentials and test access:
export AWS_ACCESS_KEY_ID="ASIA..." export AWS_SECRET_ACCESS_KEY="..." export AWS_SESSION_TOKEN="..." # Verify admin access (e.g., list EC2 instances) aws ec2 describe-instances
After 1 hour, the credentials expire automatically.
Use AWS Lambda + CloudWatch Events to auto-revoke sessions after a set time.
# Create a Lambda function (Python) to revoke sessions cat > revoke-session.py << 'EOF' import boto3 def lambda_handler(event, context): client = boto3.client('iam') response = client.list_users() for user in response['Users']: if 'dev-user' in user['UserName']: client.delete_access_key(UserName=user['UserName'], AccessKeyId=event['AccessKeyId']) return {'statusCode': 200} EOF
Trigger the Lambda via CloudWatch after 1 hour.
us-east-1
Purpose=JIT-Admin
Owner=DevOps
AssumeRole
*
ec2:StartInstances
Permanent admin rights.
"What’s the risk of not using PAM?"
"It’s fine, we trust our team."
"Which tool is used for session monitoring?"
Challenge: You’re a DevOps engineer. A developer needs temporary sudo access on a Linux server to debug a production issue. Implement JIT access using sudo and pam_time.
pam_time
Solution:1. Edit /etc/sudoers to allow dev-user to run sudo only during business hours (9 AM–5 PM): bash dev-user ALL=(ALL) ALL, !authenticate, TIMES=0900-17002. Restrict sudo to specific commands (e.g., only systemctl restart nginx): bash dev-user ALL=(root) /bin/systemctl restart nginx3. Test: bash sudo -l # Check allowed commands sudo systemctl restart nginx # Works sudo bash # Fails (not allowed)
/etc/sudoers
bash dev-user ALL=(ALL) ALL, !authenticate, TIMES=0900-1700
bash dev-user ALL=(root) /bin/systemctl restart nginx
bash sudo -l # Check allowed commands sudo systemctl restart nginx # Works sudo bash # Fails (not allowed)
Why it works: - pam_time enforces time-based restrictions. - sudoers limits commands to least privilege.
sudoers
aws sts assume-role
aws sts assume-role --role-arn arn:aws:iam::123456789012:role/JIT-Admin --role-session-name Test
sudo -l
sudo -l -U dev-user
dev-user ALL=(root) /bin/systemctl restart nginx
/etc/security/time.conf
aws:MultiFactorAuthPresent: true
PAM and JIT aren’t just "nice-to-haves"—they’re non-negotiable in modern security. Start small:1. Audit your privileged accounts (who has sudo, AWS admin, DB sa?).2. Implement JIT for one high-risk system (e.g., production DB).3. Enforce MFA and session logging for all JIT requests.
Do this today, and you’ll sleep better knowing attackers can’t move laterally with stolen admin creds. ?
Join 4M+ learners. Unlock unlimited quizzes, wrong-answer tracking, flashcards + reminders, study guides, and 1-on-1 challenges.