Stop wasting time with manual user creation on Oracle Cloud Infrastructure! This comprehensive guide provides production-ready automation scripts that intelligently detect existing users and create the next available sequential username (user1, user2, user3...) with complete SSH key configuration and enterprise security.
🎯 Perfect for: DevOps Engineers | Cloud Architects | System Administrators | DBAs | Development Teams
⚡ Results: Reduce provisioning time from 10 minutes to 15 seconds per user | Zero configuration errors | Enterprise-grade security
Complete Guide: Automate Sequential User Creation on Oracle Cloud Infrastructure (OCI)
📑 Complete Tutorial Navigation
Prerequisites & Requirements
Before implementing sequential user automation on your Oracle Cloud Infrastructure instances, ensure your environment meets these essential requirements:
✅ Active OCI Compute Instance: Running Oracle Linux, RHEL, CentOS, or Ubuntu
✅ Administrative Access: Ability to SSH as 'opc' user with sudo privileges
✅ SSH Key Pair: Your RSA 4096-bit key (pre-configured in scripts below)
✅ Network Access: Port 22 open in Security Lists for SSH connections
✅ Basic Linux Knowledge: Understanding of users, permissions, and SSH concepts
✅ Storage Space: Sufficient disk space for user home directories
The scripts below are pre-configured with your Termius-generated RSA 4096-bit SSH public key. This key will be automatically deployed to all created users, providing immediate secure access without additional configuration steps.
Understanding Sequential User Logic
The sequential user creation system follows intelligent detection logic that prevents conflicts and ensures organized user management across your OCI infrastructure:
🔄 SEQUENTIAL DETECTION ALGORITHM: START ↓ Check if user1 exists using 'id user1' ↓ [NO] → Create user1 → Configure SSH → Grant Sudo → DONE ✅ ↓ [YES] → Check if user2 exists using 'id user2' ↓ [NO] → Create user2 → Configure SSH → Grant Sudo → DONE ✅ ↓ [YES] → Continue checking user3, user4, user5... ↓ Create first available username in sequence
🚀 5-Minute Quick Start Guide
Get your first sequential user operational in under 5 minutes with this streamlined process:
Connect to Your OCI Instance
ssh -i ~/.ssh/your_private_key opc@your_instance_ip
Create and Save the Script
nano create_next_user.sh # Paste script content from next section # Save: Ctrl+O, Enter, Ctrl+X
Execute the Automation
chmod +x create_next_user.sh sudo ./create_next_user.sh
Your first sequential user (user1) is now ready with SSH access and sudo privileges. Run the script again to create user2, user3, and beyond!
📝 Simple Script Version (Beginner-Friendly)
This streamlined script creates one user per execution with comprehensive error handling and professional output formatting:
#!/bin/bash
################################################################################
# Script: create_next_user.sh
# Purpose: Create next sequential user (user1, user2, etc.) with SSH access
# Author: Himanshu Singh - Oracle ACE Pro ♠
# Website: funoracleapps.com
# Usage: sudo ./create_next_user.sh
################################################################################
set -euo pipefail
# pass your public key#
# Your SSH Public Key (Termius Generated - RSA 4096-bit)
SSH_PUBLIC_KEY="ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDn/zb+jO2FjASdFNcI1PeMEpZoudoqzIHn8mC90bsqnkG4BfpW+03kBqNBcKOhZhMeiadn5l3uhLLCyT3P/+7XEjRfDWoj71llLPIAHZi/bQDkaG3Yiq0kr6OQAjnwrzS9VyVsDTXr9Qh75OfpCyitxbE2ddg4OAKz3UiubGO5NiiXijxEAtnnPvNhW6mkIUI+4SRRfc0L71DGYDb+/uZtRaqg9+vQRkHA2uSppKI/9Lv6tMsjtCW32gjziyBkqa0C/rkLUa7AQDTxes8GPyRUTq1PcgomWwDnNLjWTqHE+uLVIpev7gUSztxC2pOcxJJ1aeC6XzfNkWapXJ+vxLi7++AT93/"
# Color codes for professional output
GREEN='\033[0;32m'
RED='\033[0;31m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m'
# Helper functions
log_success() { echo -e "${GREEN}✅ $1${NC}"; }
log_error() { echo -e "${RED}❌ $1${NC}" >&2; }
log_info() { echo -e "${BLUE}ℹ️ $1${NC}"; }
log_warning() { echo -e "${YELLOW}⚠️ $1${NC}"; }
die() {
log_error "$*"
exit 1
}
# Check root privileges
require_root() {
[[ $EUID -eq 0 ]] || die "This script must be run as root. Use: sudo $0"
}
# Find next available username in sequence
get_next_username() {
local n=1
local candidate
while true; do
candidate="user${n}"
if ! id "$candidate" &>/dev/null; then
echo "$candidate"
return 0
fi
log_info "User $candidate already exists, checking next..."
((n++))
done
}
# Create user with complete SSH and sudo configuration
create_user() {
local username="$1"
local home_dir="/home/${username}"
local ssh_dir="${home_dir}/.ssh"
local auth_keys="${ssh_dir}/authorized_keys"
local sudoers_file="/etc/sudoers.d/${username}"
echo ""
echo "═══════════════════════════════════════════════════"
echo " Creating User: ${username}"
echo "═══════════════════════════════════════════════════"
echo ""
# Create user account with bash shell
log_info "Creating user account..."
useradd -m -s /bin/bash "${username}" || die "Failed to create user ${username}"
log_success "User account created successfully"
# Set up SSH directory and authorized_keys
log_info "Configuring SSH access..."
mkdir -p "${ssh_dir}"
echo "${SSH_PUBLIC_KEY}" > "${auth_keys}"
# Set critical SSH permissions
chmod 700 "${ssh_dir}"
chmod 600 "${auth_keys}"
chown -R "${username}:${username}" "${ssh_dir}"
log_success "SSH access configured with proper permissions"
# Configure passwordless sudo access
log_info "Granting sudo privileges..."
echo "${username} ALL=(ALL) NOPASSWD:ALL" > "${sudoers_file}"
chmod 440 "${sudoers_file}"
# Validate sudoers file syntax
if visudo -c -f "${sudoers_file}" &>/dev/null; then
log_success "Sudo privileges configured and validated"
else
log_error "Invalid sudoers configuration, removing file"
rm -f "${sudoers_file}"
return 1
fi
# Add to wheel group if available (RHEL/OEL)
if getent group wheel >/dev/null 2>&1; then
usermod -aG wheel "${username}"
log_success "Added to wheel group for additional sudo access"
fi
# Display connection information
local instance_ip=$(hostname -I | awk '{print $1}')
echo ""
echo "🎉 SUCCESS! User '${username}' created and configured!"
echo ""
echo "📋 User Details:"
echo " 👤 Username: ${username}"
echo " 🏠 Home Directory: ${home_dir}"
echo " 🐚 Shell: /bin/bash"
echo " 🔐 SSH Access: Enabled with your Termius key"
echo " ⚡ Sudo Access: Passwordless (NOPASSWD:ALL)"
echo ""
echo "🔗 SSH Connection Command:"
echo " ssh -i ~/.ssh/id_rsa ${username}@${instance_ip}"
echo ""
echo "💡 Pro Tip: Test the connection before disconnecting from current session!"
echo ""
}
# Main execution function
main() {
echo "═══════════════════════════════════════════════════"
echo " OCI Sequential User Provisioning Script"
echo " by Himanshu Singh (Oracle ACE Pro ♠)"
echo " Website: funoracleapps.com"
echo "═══════════════════════════════════════════════════"
echo ""
require_root
NEXT_USER="$(get_next_username)"
create_user "${NEXT_USER}"
echo "🎯 Next execution will create: user$((${NEXT_USER#user} + 1))"
echo ""
}
main "$@"
# First run - creates user1 sudo ./create_next_user.sh # Second run - creates user2 (user1 already exists) sudo ./create_next_user.sh # Third run - creates user3 sudo ./create_next_user.sh # Verify all created users getent passwd | grep '^user[0-9]' | cut -d: -f1
🏢 Production-Ready Script (Enterprise Grade)
For enterprise environments requiring batch user creation, comprehensive logging, and advanced error handling:
#!/bin/bash
################################################################################
# Script: provision_oci_users_enterprise.sh
# Purpose: Enterprise-grade sequential user provisioning for OCI instances
# Author: Himanshu Singh - Oracle ACE Pro ♠
# Website: funoracleapps.com
# Usage: sudo ./provision_oci_users_enterprise.sh [number_of_users]
# Examples:
# sudo ./provision_oci_users_enterprise.sh # Create 1 user
# sudo ./provision_oci_users_enterprise.sh 5 # Create 5 users
# sudo ./provision_oci_users_enterprise.sh 25 # Create 25 users
################################################################################
set -euo pipefail
# pass your public key#
# Configuration
SSH_PUBLIC_KEY="ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDn/zb+jO2FjASdFNcI1PeMEpZoudoqzIHn8mC90bsqnkG4BfpW+03kBqNBcKOhZhMeiadn5l3uhLLCyT3P/+7XEjRfDWoj71llLPIAHZi/bQDkaG3Yiq0kr6OQAjnwrzS9VyVsDTXr9Qh75OfpCyitxbE2ddg4OAKz3UiubGO5NiiXijxEAtnnPvNhW6mkIUI+4SRRfc0L71DGYDb+/uZtRaqg9+vQRkHA2uSppKI/9Lv6tMsjtCW32gjziyBkqa0C/rkLUa7AQDTxes8GPyRUTq1PcgomWwDnNLjWTqHE+uLVIpev7gUSztxC2pOc"
USER_PREFIX="user"
BASE_UID=2000
LOG_FILE="/var/log/oci_user_provisioning.log"
# Enhanced color codes
GREEN='\033[0;32m'
RED='\033[0;31m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
CYAN='\033[0;36m'
MAGENTA='\033[0;35m'
NC='\033[0m'
# Professional logging functions
log_message() {
local msg="[$(date '+%Y-%m-%d %H:%M:%S')] $1"
echo -e "${GREEN}$msg${NC}"
echo "$msg" >> "$LOG_FILE"
}
log_error() {
local msg="[ERROR] $1"
echo -e "${RED}$msg${NC}" >&2
echo "$msg" >> "$LOG_FILE"
}
log_info() {
local msg="[INFO] $1"
echo -e "${CYAN}$msg${NC}"
echo "$msg" >> "$LOG_FILE"
}
# Root privilege validation
check_root() {
if [[ $EUID -ne 0 ]]; then
log_error "This script must be run as root (use sudo)"
echo ""
echo -e "${YELLOW}Usage Examples:${NC}"
echo " sudo $0 # Create 1 user"
echo " sudo $0 5 # Create 5 users"
echo " sudo $0 25 # Create 25 users"
exit 1
fi
}
# Intelligent user number detection
find_next_user() {
local counter=1
while id "${USER_PREFIX}${counter}" &>/dev/null; do
((counter++))
done
echo "$counter"
}
# Comprehensive user creation with validation
create_user() {
local username="$1"
local user_number="$2"
local uid=$((BASE_UID + user_number))
log_info "Creating user: $username (UID: $uid)"
# Create user with specific UID to avoid conflicts
if ! useradd -m -s /bin/bash -u "$uid" "$username" 2>/dev/null; then
log_error "Failed to create user $username (UID $uid may be in use)"
return 1
fi
# SSH directory and key configuration
local user_home="/home/$username"
local ssh_dir="$user_home/.ssh"
local auth_keys="$ssh_dir/authorized_keys"
mkdir -p "$ssh_dir"
echo "$SSH_PUBLIC_KEY" > "$auth_keys"
# Critical permission settings for SSH security
chmod 700 "$ssh_dir"
chmod 600 "$auth_keys"
chown -R "$username:$username" "$ssh_dir"
# Sudo access configuration with validation
local sudoers_file="/etc/sudoers.d/$username"
cat > "$sudoers_file" << EOF
# Sudo configuration for $username
# Created: $(date)
# Purpose: OCI instance administration
$username ALL=(ALL) NOPASSWD:ALL
EOF
chmod 440 "$sudoers_file"
# Validate sudoers syntax
if ! visudo -c -f "$sudoers_file" &>/dev/null; then
log_error "Invalid sudoers configuration for $username"
rm -f "$sudoers_file"
return 1
fi
# Add to appropriate groups
if getent group wheel > /dev/null 2>&1; then
usermod -aG wheel "$username"
fi
if getent group sudo > /dev/null 2>&1; then
usermod -aG sudo "$username"
fi
log_message "✅ User $username provisioned successfully"
return 0
}
# Comprehensive summary display
display_summary() {
local created_users=("$@")
local instance_ip=$(hostname -I | awk '{print $1}')
local instance_name=$(hostname)
local total_users=$(getent passwd | grep "^${USER_PREFIX}[0-9]" | wc -l)
echo ""
echo "╔══════════════════════════════════════════════════════════════════════╗"
echo "║ PROVISIONING SUMMARY ║"
echo "╚══════════════════════════════════════════════════════════════════════╝"
echo ""
echo "📊 Instance Information:"
echo " 🖥️ Hostname: $instance_name"
echo " 🌐 IP Address: $instance_ip"
echo " 📅 Date: $(date '+%Y-%m-%d %H:%M:%S')"
echo " 📝 Log File: $LOG_FILE"
echo ""
echo "👥 User Statistics:"
echo " ➕ Users Created This Run: ${#created_users[@]}"
echo " 📈 Total Sequential Users: $total_users"
echo ""
if [[ ${#created_users[@]} -gt 0 ]]; then
echo "✅ Successfully Created Users:"
for user in "${created_users[@]}"; do
echo " 👤 $user"
done
echo ""
echo "🔗 SSH Connection Commands:"
for user in "${created_users[@]}"; do
echo " ssh -i ~/.ssh/id_rsa $user@$instance_ip"
done
echo ""
echo "💡 Quick Commands:"
echo " • List all users: getent passwd | grep '^user[0-9]'"
echo " • Check user details: id user1 && groups user1"
echo " • View logs: tail -f $LOG_FILE"
echo ""
fi
echo "🎯 Next available user: ${USER_PREFIX}$(find_next_user)"
echo ""
}
# Main execution with comprehensive error handling
main() {
echo "╔══════════════════════════════════════════════════════════════════════╗"
echo "║ OCI Enterprise User Provisioning Script v2.1 ║"
echo "║ by Himanshu Singh (Oracle ACE Pro ♠) ║"
echo "║ funoracleapps.com ║"
echo "╚══════════════════════════════════════════════════════════════════════╝"
echo ""
check_root
local num_users="${1:-1}"
# Input validation
if ! [[ "$num_users" =~ ^[0-9]+$ ]] || [[ "$num_users" -lt 1 ]] || [[ "$num_users" -gt 100 ]]; then
log_error "Invalid input. Number must be between 1 and 100."
echo ""
echo "Valid Examples:"
echo " sudo $0 # Create 1 user"
echo " sudo $0 10 # Create 10 users"
echo " sudo $0 50 # Create 50 users"
exit 1
fi
log_message "Starting user provisioning session..."
log_info "Requested users: $num_users"
local created_users=()
local start_number=$(find_next_user)
log_info "Starting from: ${USER_PREFIX}${start_number}"
# Progress tracking for batch operations
echo ""
echo "🚀 Provisioning Progress:"
for ((i=0; i/dev/null; then
echo -e "\n ⚠️ User $username already exists, skipping..."
continue
fi
if create_user "$username" "$user_number"; then
created_users+=("$username")
echo -e "\n ✅ $username created successfully"
else
echo -e "\n ❌ Failed to create $username"
fi
done
echo ""
if [[ ${#created_users[@]} -eq 0 ]]; then
log_warning "No new users were created (all requested users already exist)"
echo ""
echo "Next available user would be: ${USER_PREFIX}$(find_next_user)"
exit 0
fi
display_summary "${created_users[@]}"
echo "🎉 User provisioning completed successfully!"
echo ""
}
main "$@"
# Create single user (next in sequence) sudo ./provision_oci_users_enterprise.sh # Create 5 users for development team sudo ./provision_oci_users_enterprise.sh 5 # Create 25 users for training class sudo ./provision_oci_users_enterprise.sh 25 # View detailed logs with timestamps cat /var/log/oci_user_provisioning.log # List all sequential users on system getent passwd | grep '^user[0-9]' | cut -d: -f1 | sort -V
✅ Complete Verification & Testing Guide
After provisioning users, perform these comprehensive verification tests to ensure everything is configured correctly:
**Essential Verification Commands:**# 1. List all sequential users created
getent passwd | grep '^user[0-9]' | cut -d: -f1
# 2. Check specific user details
id user1
groups user1
# 3. Verify home directory and SSH setup
ls -la /home/user1
ls -la /home/user1/.ssh/
# 4. Verify SSH key is properly configured
cat /home/user1/.ssh/authorized_keys | head -c 100
# 5. Test sudo access
sudo -l -U user1
# 6. Verify sudoers file syntax
sudo visudo -c -f /etc/sudoers.d/user1
# 7. Test local SSH connection
ssh -i ~/.ssh/id_rsa user1@localhost
# 8. Check SSH service status
sudo systemctl status sshd
# 9. View recent authentication logs
sudo tail -20 /var/log/secure # RHEL/OEL
sudo tail -20 /var/log/auth.log # Ubuntu/Debian
# 10. Test from external machine
ssh -i ~/.ssh/id_rsa user1@$(hostname -I | awk '{print $1}')
• All users should appear in passwd database
• SSH directories should have 700 permissions
• authorized_keys files should have 600 permissions
• Users should be able to sudo without passwords
• SSH connections should work immediately
🔒 Security Best Practices & Hardening
Implement these enterprise-grade security measures to protect your OCI instances and user accounts:
**Essential Security Hardening Script:**#!/bin/bash # OCI Security Hardening for Sequential Users # 1. Disable password authentication completely sudo sed -i 's/#PasswordAuthentication yes/PasswordAuthentication no/' /etc/ssh/sshd_config sudo sed -i 's/PasswordAuthentication yes/PasswordAuthentication no/' /etc/ssh/sshd_config # 2. Configure SSH security settings cat >> /etc/ssh/sshd_config << 'EOF' # Enhanced security settings ClientAliveInterval 300 ClientAliveCountMax 2 MaxAuthTries 3 MaxSessions 10 PermitRootLogin no EOF sudo systemctl restart sshd # 3. Install and configure fail2ban for brute force protection sudo yum install epel-release -y sudo yum install fail2ban -y sudo tee /etc/fail2ban/jail.local << 'EOF' [DEFAULT] bantime = 3600 findtime = 600 maxretry = 3 [sshd] enabled = true port = ssh logpath = /var/log/secure maxretry = 3 EOF sudo systemctl enable fail2ban sudo systemctl start fail2ban # 4. Configure firewall (if not using OCI Security Lists exclusively) sudo firewall-cmd --permanent --add-service=ssh sudo firewall-cmd --reload # 5. Enable automatic security updates sudo yum install yum-cron -y sudo systemctl enable yum-cron echo "✅ Security hardening completed successfully!"
The scripts grant passwordless sudo access (NOPASSWD:ALL) for development convenience. For production environments, consider:
• Removing NOPASSWD and requiring password confirmation
• Implementing role-based sudo permissions
• Using dedicated SSH keys per user or team
• Enabling comprehensive audit logging
• Regular access reviews and account cleanup
🔧 Comprehensive Troubleshooting Guide
Symptoms:
Permission denied (publickey,gssapi-keyex,gssapi-with-mic)Root Causes: Incorrect SSH directory permissions, wrong file ownership, or malformed authorized_keys
Solutions:
# Fix all SSH permissions as root sudo chmod 700 /home/user1/.ssh sudo chmod 600 /home/user1/.ssh/authorized_keys sudo chown -R user1:user1 /home/user1/.ssh # Verify permissions are correct ls -la /home/user1/.ssh/ # Should show: drwx------ for .ssh directory # Should show: -rw------- for authorized_keys # Restore SELinux context (RHEL/OEL only) sudo restorecon -Rv /home/user1/.ssh # Test SSH key format ssh-keygen -lf /home/user1/.ssh/authorized_keys
Symptoms:
ssh: connect to host X.X.X.X port 22: Connection refusedSolutions:
# Check SSH service status sudo systemctl status sshd # Start SSH service if stopped sudo systemctl start sshd sudo systemctl enable sshd # Check if SSH is listening on port 22 sudo netstat -tlnp | grep :22 # OR sudo ss -tlnp | grep :22 # Check firewall configuration sudo firewall-cmd --list-all sudo firewall-cmd --permanent --add-service=ssh sudo firewall-cmd --reload # Verify OCI Security List allows port 22 from your IP
Symptoms: Script exits with error during user creation
Solutions:
# Check available disk space df -h # Check for UID conflicts id 2001 # Should return "no such user" # Verify /etc/passwd is not locked lsof /etc/passwd /etc/shadow # Check system user limits cat /etc/login.defs | grep UID # Test manual user creation sudo useradd -m -s /bin/bash test_user sudo userdel -r test_user # Clean up test
❓ Frequently Asked Questions
These are the most common questions from DBAs and cloud engineers using our automation scripts.
A: Absolutely! Modify the USER_PREFIX="user" variable in the script:
# For development team USER_PREFIX="dev" # Creates: dev1, dev2, dev3... # For database administrators USER_PREFIX="dba" # Creates: dba1, dba2, dba3... # For students/training USER_PREFIX="student" # Creates: student1, student2, student3... # For temporary contractors USER_PREFIX="temp" # Creates: temp1, temp2, temp3...
# Complete user removal (destructive - be careful!) sudo userdel -r user3 # Remove user and home directory sudo rm -f /etc/sudoers.d/user3 # Remove sudo configuration sudo rm -f /var/log/user3_* # Remove any user-specific logs # Verify complete removal id user3 # Should return "no such user" ls /home/ | grep user3 # Should return nothing
A: The production script limits batch creation to 100 users per execution for safety and performance. However, you can run it multiple times. The theoretical system limit is typically 65,534 users (based on UID range), but practical limits depend on available storage and memory.
**Q: Will this work on all Linux distributions?**A: Yes! The scripts are designed for cross-distribution compatibility and work on:
- ✅ Oracle Linux (most common on OCI)
- ✅ Red Hat Enterprise Linux (RHEL)
- ✅ CentOS / Rocky Linux
- ✅ Ubuntu (all LTS versions)
- ✅ Debian
# Instead of: user1 ALL=(ALL) NOPASSWD:ALL # Use command-specific restrictions: # Allow only systemctl and service management user1 ALL=(ALL) NOPASSWD: /usr/bin/systemctl, /sbin/service # Allow database-specific commands for DBAs user1 ALL=(ALL) NOPASSWD: /usr/bin/sqlplus, /u01/app/oracle/product/*/bin/* # Allow monitoring commands only user1 ALL=(ALL) NOPASSWD: /usr/bin/top, /usr/bin/htop, /bin/ps, /usr/bin/netstat
🌟 Real-World Usage Scenarios
# Create 5 developer accounts in one command
sudo ./provision_oci_users_enterprise.sh 5
# Verify all users created
getent passwd | grep '^user[0-9]'
# Generate connection instructions for team lead
echo "Development Team SSH Access:" > dev_team_access.txt
for i in {1..5}; do
echo "Developer $i: ssh -i ~/.ssh/id_rsa user$i@$(hostname -I | awk '{print $1}')" >> dev_team_access.txt
done
cat dev_team_access.txt
# Create 20 student accounts for Oracle training
sudo ./provision_oci_users_enterprise.sh 20
# Create welcome message for each student
for i in {1..20}; do
cat > /home/user$i/welcome.txt << EOF
Welcome to Oracle Cloud Training!
Your username: user$i
Your home directory: /home/user$i
Instance IP: $(hostname -I | awk '{print $1}')
Training materials: /opt/training/
EOF
chown user$i:user$i /home/user$i/welcome.txt
done
# Generate instructor reference
echo "Student Access List - $(date)" > student_access.txt
for i in {1..20}; do
echo "Student $i: ssh -i ~/.ssh/id_rsa user$i@$(hostname -I | awk '{print $1}')" >> student_access.txt
done
# Create 3 contractor accounts
sudo ./provision_oci_users_enterprise.sh 3
# Set account expiration (30 days from now)
for i in {1..3}; do
sudo chage -E $(date -d "+30 days" +%Y-%m-%d) user$i
echo "Account user$i expires: $(date -d "+30 days" +%Y-%m-%d)"
done
# Create automated cleanup script for later
cat > cleanup_contractors.sh << 'EOF'
#!/bin/bash
echo "Removing contractor accounts..."
for i in {1..3}; do
sudo userdel -r user$i 2>/dev/null || true
sudo rm -f /etc/sudoers.d/user$i
echo "✅ Removed user$i"
done
echo "Contractor cleanup completed."
EOF
chmod +x cleanup_contractors.sh
🎯 Summary & Next Steps
You've successfully mastered automated sequential user creation on Oracle Cloud Infrastructure! This powerful automation eliminates manual errors, dramatically reduces provisioning time, and provides enterprise-grade security consistency across all user accounts.
✅ Massive Time Savings: Reduced user provisioning from 10+ minutes to 15 seconds per user
✅ Zero Configuration Errors: Eliminated manual SSH permission and sudo configuration mistakes
✅ Unlimited Scalability: Create hundreds of users effortlessly with consistent configuration
✅ Enterprise Security: Automated SSH key deployment with proper permission management
✅ Production Ready: Comprehensive logging, error handling, and validation built-in
✅ Cross-Platform: Works on all major Linux distributions used in OCI
1. Test in Development: Start with the simple script on a test instance
2. Implement Security Hardening: Apply the security configurations for production use
3. Customize for Your Environment: Modify username prefixes and sudo permissions as needed
4. Document Your Process: Create runbooks for your team using these scripts
5. Scale Across Infrastructure: Deploy automation across multiple OCI instances
6. Monitor and Maintain: Regular access reviews and account lifecycle management
Share this automation with your team to standardize user provisioning across your Oracle Cloud infrastructure and eliminate the time-consuming manual processes that slow down your operations!
🎥 Master Oracle Cloud with Expert Tutorials
Join 25,000+ Oracle professionals learning advanced OCI techniques, database administration, automation strategies, and cloud architecture best practices from an Oracle ACE Pro.
▶️ Subscribe to @foalabs Channel💬 Questions about OCI automation? Drop them in the comments below!
If you like this post please follow, share and comment
Post a Comment
Post a Comment