Skip to content

DimitryZH/bash-user-management-script

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

Bash User Management Script

Project Description:

The "Bash User Management Script" is a Bash script designed to automate the process of creating a new user account on a Unix-like system and setting up SSH access for that user. This project aims to simplify and streamline the administrative tasks involved in user management, particularly in environments where multiple user accounts need to be provisioned quickly and consistently.

Features:

  1. Interactive User Input: The script prompts the administrator for essential information, such as the username, password, and SSH public key path, ensuring flexibility and customization for each new user.

  2. Secure Password Entry: The script hides the password input while prompting the administrator, enhancing security by preventing password visibility during entry.

  3. SSH Key Management: It automates the process of appending the provided SSH public key to the user's authorized_keys file, enabling secure SSH access without the need for manual configuration.

  4. Home Directory Setup: The script copies skeleton files from /etc/skel to the new user's home directory, ensuring that the user has a consistent environment upon login.

  5. User Account Creation: It adds the new user with the specified home directory and shell, simplifying the user provisioning process.

  6. Permissions Management: The script sets appropriate ownership and permissions for the user's home directory, ensuring that the user has proper access to their files and directories.

  7. Password Setting: It securely sets the password for the new user, ensuring that the account is properly secured upon creation.

Implementation:

To implement the "Bash User Management Script," follow these steps:

  1. Create SSH Key:

    dmitry@ubuntuserver:~/scripts$ ssh-keygen
  2. Create "scripts" folder:

    dmitry@ubuntuserver:~$ mkdir scripts
  3. Create script file:

    dmitry@ubuntuserver:~/scripts$ touch create_user_ssh_pub.sh
  4. Paste script code into the text editor:

create-user-script

  1. Execute the script:

    dmitry@ubuntuserver:~/scripts$ sudo bash create_user_ssh_pub.sh
  2. Enter user, password, and SSH public key path:

    • SSH public key path: "/home/dmitry/.ssh/id_rsa.pub"

Results:

Below are the screenshots of the script execution with the user entering the password, login, etc., and the results of verifying the new user:

  1. create-user-script-result_1
  2. create-user-script-result_2
  3. create-user-script-result_3

These screenshots demonstrate the script execution process, including the input of password, login, etc., as well as the verification of the results by logging in under the new user and checking cat /etc/passwd and cat /etc/group.

Conclusion:

The "Bash User Management Script" project aims to simplify and automate user management tasks on Unix-like systems, enhancing administrative efficiency and consistency. This project offers a reliable and user-friendly solution for system administrators and DevOps professionals. Contributions are welcome.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages