Random Password Generator Development

ShellIntermediate
Practice Now

Introduction

In this challenge, we will implement a bash script called genpass.sh that generates random passwords. The generated password should be 12 characters long and meet specific requirements: it must contain at least one digit, one uppercase letter, one lowercase letter, and one special character. The goal is to create a password generator that meets these conditions and returns a different password each time it is executed. We will explore topics such as the Linux random number generator and the basics of bash script programming.

Password Generator

In the LabEx environment, the username for each user is labex, but the passwords are random.

Please implement a random password generator that meets the following requirements:

  • The generated password should be 12 characters long.
  • The password must contain at least one digit, one uppercase letter, one lowercase letter, and one special character.
  • Only the following special characters are allowed: ><+-{}:.&;.

Goals

  • Write the required zsh script into the genpass.sh file already created in the /home/labex/project directory.
  • The genpass.sh script needs to meet the three conditions described in the introduction, and each execution should generate a different password.
  • Do not use ready-made password generation tools like mkpasswd on Linux.
  • The password generation script should return a password that meets the requirements each time it is executed.

Output

$ cd /home/labex/project
$ sh genpass.sh
2Dsxw9+xS:27

Summary

Congratulations! You have completed the Password Generator challenge. You can practice more labs in LabEx to improve your skills.

✨ Check Solution and Practice