# multi-server-user-manager
**Automate user creation and removal across multiple Linux servers from a single script.**
---
## Overview
`set_local_user.sh` is a Bash automation tool for centralized user management on multiple Linux servers.
It streamlines user creation, account removal, and home directory setup—ensuring consistent environments across your infrastructure.
---
## Features
- Create new users on all servers from a single command.
- Remove users from all servers and the tracking file (without deleting their data).
- Automatically create and permission user home/work directories on network storage.
- Distribute SSH keys and aliases to network home directories.
- Interactive and safe: all actions are performed via clear, step-by-step prompts.
---
## Usage
### 1. Ensure Prerequisites
- Run the script as **root**.
- Ensure SSH key access to all target servers.
- Update file paths for server/user lists and NFS/project directories if needed.
### 2. Run the Script
```sh
bash set_local_user.shYou will be guided step-by-step via the following prompts and instructions:
Welcome! Please choose an action from the list:
1 - Create new user on Zebu
2 - Delete entry only of leaving user (Without DATA)
:
-
Prompt:
Enter username to add: -
If the username is empty:
Username cannot be empty. -
If the user already exists in the tracking file:
User <username> already exists in the users list. -
If the user is new:
User <username> added to the users list. -
For each server in your server list:
Connecting to <server>...-
If the user does not exist on the server:
User <Full Name> created successfully on <server>. User creation on <server> successful. -
If the user already exists on the server:
User <username> already exists on <server>. No action taken.
-
-
When copying SSH keys and aliases:
Copying SSH keys and .tcshrc.* and Alias files -
After updating ownerships:
Updating user ownership on directory /net/<IP-Address>/vol_home_01/ -
After creating the work directory:
Work directory at /projects/<>/work/ for User '<Full Name>' created successfully -
After creating the home directory:
Home directory at /projects/<>/home/ for User '<Full Name>' created successfully
-
Prompt:
Enter username to remove: -
If the username is empty:
Username cannot be empty. -
If the user is found in the tracking file:
User <username> removed from the users list. -
If the user is not found:
User <username> not found in the users list. -
For each server in your server list:
Connecting to <server>...-
If the user does not exist on the server:
User <username> does not exist on <server>. Skipping deletion. -
If the user is deleted successfully:
User <Full Name> deleted successfully on <server>. User <Full Name> deleted on <server> successfully. -
If deletion fails:
Failed to delete <Full Name> user on <server>.
-
-
When checking for empty directories:
Checking if empty directory exists at /projects/<>/-
If the work directory was deleted:
User '<Full Name>' had an empty work directory at /projects/<>/work/<username> ; Deleted successfully. -
If the home directory was deleted:
User '<Full Name>' had an empty home directory at /projects/<>/home/<username> ; Deleted successfully.
-
Welcome! Please choose an action from the list:
1 - Create new user on Zebu
2 - Delete entry only of leaving user (Without DATA)
: 1
Enter username to add: johndoe
User johndoe added to the users list.
Connecting to server1...
User John Doe created successfully on server1.
User creation on server1 successful.
Copying SSH keys and .tcshrc.* and Alias files
Updating user ownership on directory /net/<IP-Address>/vol_home_01/
Work directory at /projects/<>/work/ for User 'John Doe' created successfully
Home directory at /projects/<>/home/ for User 'John Doe' created successfully- Bash
- SSH access to all managed servers
- Root privileges
- Server list file (default:
/tools/IT/script/server_list.txt) - User list file (default:
/tools/IT/.users_list)
Warning: This script modifies user accounts and system files on multiple servers. Run only if you understand the implications. Use at your own risk; no warranty or liability is provided.
This project is distributed under the MIT License. See LICENSE for more information.
---
Let me know if you want this as a downloadable file or if you want even more details or troubleshooting tips!