Error: User modify failed. Cannot modify user on other node: usermod: user luca does not exist.
Error: User modify failed. Cannot modify user on other node: usermod: user ’luca’ does not exist.
Overview: This article addresses the error message encountered when attempting to modify a non-existent user on the Master node of a web GUI: Error: User modify failed. Cannot modify user on other node: usermod: user ‘luca’ does not exist. The issue arises because the specified user does not exist on the node where the modification is being attempted. This guide provides solutions, including adding the user on the Slave node or leveraging an automated script to create missing system users efficiently.
Cause: The error occurs when trying to modify a gateway user from the GUI (Master node) without the user being present on the Slave node (Secondary node). The system requires the user to exist on both nodes to apply modifications correctly.
Step 1: Add the user on the Slave node (Secondary node server).
To resolve this, manually add the missing user on the Slave node by executing the following command:
root@secondary :~# useradd -K UMASK=0077 -m -s '/usr/local/bin/ezsh' -g 'ezuser'username
Example: root@secondary:~# useradd -K UMASK=0077 -m -s '/usr/local/bin/ezsh' -g 'ezuser'luca
This command creates the user with the appropriate configurations on the Secondary node, ensuring consistency across nodes.
Alternative Method.
Step 2: An alternative approach is to remove the gateway user from the Master node and then recreate it in the web GUI.
However, note that this method will result in the loss of user logs.
Automating user creation across nodes.
To prevent similar issues in the future, you can automate the creation of system users using a bash script that retrieves usernames from a MySQL database.
1. Create a bash script named usercreate_script.sh to check for and add missing users automatically.
root@gateway:~# vim usercreate_script.sh
2. Insert the script.
!/bin/bash
# MySQL root password
sqlpass="YourMySQLRootPassword"
# Retrieve database and table names
db_name=$(awk -F ' ' '/db_name/ {print $2}' /usr/local/etc/ezlogin/ez.conf)
tbl_prefix=$(awk -F ' ' '/db_prefix/ {print $2}' /usr/local/etc/ezlogin/ez.conf)
tbl_name="${tbl_prefix}users"
# Retrieve usernames from MySQL
usernames=$(mysql -u root -p"${sqlpass}" -D "$db_name" -N -e "SELECT username FROM $tbl_name")
#Loop through each username and add the user if they do not exist
for username in $usernames; do
if ! id -u "$username" >/dev/null 2>&1; then
useradd -m -s /usr/local/bin/ezsh "$username"
echo "Adding user $username to the system..."
fi
done
3. Execute the script.
root@gateway:~# sh usercreate_script.sh
This script ensures that all required users exist across nodes, minimizing manual intervention and reducing the likelihood of encountering the modification error in the future.
Related Articles:
Reset the User password and update in Ezeelogin.