Skip to content

Commit

Permalink
Use /etc/sudoers.d/ to configure admin user sudo rights
Browse files Browse the repository at this point in the history
  • Loading branch information
Teemu Matilainen authored and andsens committed Jan 17, 2013
1 parent 3a81130 commit 6fd5620
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions plugins/admin-user-tasks/create-user
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
#!/bin/bash
admin_username='admin'

# Create the user and add him to the 'sudo' group
# Create the user
chroot $imagedir useradd --create-home --shell /bin/bash $admin_username

# Allow ec2-user to use sudo without a password
sed -i "/^root\tALL=(ALL) ALL/a $admin_username\tALL=(ALL) NOPASSWD: ALL" $imagedir/etc/sudoers
cat > $imagedir/etc/sudoers.d/99_admin <<EOF
$admin_username ALL=(ALL) NOPASSWD:ALL
EOF
chmod 440 $imagedir/etc/sudoers.d/99_admin

# ec2-get-credentials should add the pubkey to the new user account and not root
sed -i "s/^username='root'/username='$admin_username'/" $imagedir/etc/init.d/ec2-get-credentials
Expand Down

0 comments on commit 6fd5620

Please sign in to comment.