- Launch an EC2 t2 micro ubuntu Linux instance on AWS Cloud.
- Connect to the instance from the terminal.
- Create the project folder - Shell and move into the directory.
- Create files names.csv, id_rsa, and id_rsa.pub thesame directory.
- Edit the content of id_rsa file by copying and pasting the private key into the file. Save and exit.
- Edit the content of id_rsa.pub file by copying and pasting the public key into the file. Save and exit.
- Edit the content of names.csv file by adding the first names of the users to be onboarded to the system. Save and exit.
- Create the developers group that the users will be added unto.
- Create onboard.sh file that the contain the script and paste the shell script to create the users into the file. Save and exit.
- Make the file executable by runing chmod +x onboard.sh.
- 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.
- 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.
- Verify that the users have been created.
- Check the home directory of one of the users and verify the content of the authorized key file. Exit from the terminal.
- 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.
- 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.
- Test again with another user, using thesame id_rsa.pem file to connect to the server. User connected successfully.
Click here to see brief demo video.