Skip to Content

List user and subssh user mapped

How to list the usernames and the corresponding subssh users mapped individually?


Overview: This article helps to retrieve the list of gateway users and their corresponding subssh users configured in Ezeelogin.


Step 1: Run below command to find the database name and table prefix.

root@gateway:~# cat /usr/local/etc/ezlogin/ez.conf | grep -i "db_name\|db_prefix"

db_name ezlogin_wupluh
db_prefix btu_

Step 2: Login to the MySQL and run the query below to list the usernames and the corresponding subssh users mapped individually from the user edit.

root@gateway:~# mysql -u root -p

Enter password:

mysql> use ezlogin_wupluh;

mysql> select u.username as user, s.username as sub_ssh_user from btu_users as u join btu_ssh_users as s on u.ssh_user_id = s.id;

+--------+--------------+
| user   | sub_ssh_user |
+--------+--------------+
| alex   | john         |
| tony   | nick         |
+--------+--------------+
2 rows in set (0.00 sec)

Replace the database name (ezlogin_wupluh) and table prefix (btu_) with your own values.

Execute the following command and provide the MySQL root password when prompted to get the list with a single command.

root@gateway:~# mysql -u root -p -e "USE $(grep -oP 'db_name\s+\K\S+' /usr/local/etc/ezlogin/ez.conf);select u.username as user, s.username as sub_ssh_user from $(grep -oP 'db_prefix\s+\K\S+' /usr/local/etc/ezlogin/ez.conf)users as u join $(grep -oP 'db_prefix\s+\K\S+' /usr/local/etc/ezlogin/ez.conf)ssh_users as s on u.ssh_user_id = s.id;"

Enter password:

+--------+--------------+
| user   | sub_ssh_user |
+--------+--------------+
| alex   | john         |
| tony   | nick         |
+--------+--------------+


Related Articles:

How to view the complete Server and User list via MySQL?