Skip to content

Latest commit

 

History

History
79 lines (42 loc) · 3.22 KB

File metadata and controls

79 lines (42 loc) · 3.22 KB

Shell Scripting: Onboarding of 20 users using Shell Scripting

  1. Launch an EC2 t2 micro ubuntu Linux instance on AWS Cloud.

Launch an EC2 instance

  1. Connect to the instance from the terminal.

Update packages

  1. Create the project folder - Shell and move into the directory.

create Shell directory

  1. Create files names.csv, id_rsa, and id_rsa.pub thesame directory.

create files

  1. Edit the content of id_rsa file by copying and pasting the private key into the file. Save and exit.

Edit-id_rsa Edit-id_rsa

  1. Edit the content of id_rsa.pub file by copying and pasting the public key into the file. Save and exit.

Edit-id_rsa.pub Edit-id_rsa

  1. Edit the content of names.csv file by adding the first names of the users to be onboarded to the system. Save and exit.

Edit names.csv Edit names.csv

  1. Create the developers group that the users will be added unto.

create developers group

  1. Create onboard.sh file that the contain the script and paste the shell script to create the users into the file. Save and exit.

create onboard.sh file add script into the file

  1. Make the file executable by runing chmod +x onboard.sh.

make onboard.sh executable

  1. One of the conditions in the script is that only an admin user can run the script. So run - sudo su to elevate to root user profile and then run the file with ./onboard.sh.

create onboard.sh file

  1. The 20 users are automatically created with the appropriate permission, authorised keys saved in the ssh folder in individual home directories, and password expiry information change.

create onboard.sh file

  1. Verify that the users have been created.

verify users

  1. Check the home directory of one of the users and verify the content of the authorized key file. Exit from the terminal.

verify users

  1. Test using one or two user to connect to the server using the private key and the public key. Switch to a linux machine and create a id_rsa.pem file containing the private key.

create pem file create pem file

  1. Run chmod 400 on id_rsa.pem to change the mode of the file so that the content can be private and acceptable by the AWS server. Then in thesame directory, try to connect to the server using the first names of the already created users. User connected successfully.

chmod 400 Kelly connected

  1. Test again with another user, using thesame id_rsa.pem file to connect to the server. User connected successfully.

brian connected

Click here to see brief demo video.