Disconnecting while logging into the remote server
How to solve disconnection issues when attempting to log in to a server from the backend?
Overview: This article outlines how to resolve disconnection issues when logging in to a remote server from backend by verifying the logs and addressing issues related to duplicate entries.
Step 1: Tail the latest ezsh log of the user who attempted to log in to the server. Replace the username with the actual one.
root@gateway:~# tail -f /home/username/ezsh.log
OR
Tail latest application log and try to replicate the same error encountered earlier. Replace latest_log with the actual log filename.
root@gateway:~# tail -f /var/www/ezlogin/application/logs/latest_log
The example below illustrates how to diagnose and fix issues found in the SSH logs:
Step 2: If below error appears in the log, follow the steps outlined below to resolve the issue.
root@gateway:~# tail -f /home/linda/ezsh.log
New session started from 69.90.223.10:55130 to 10.10.8.21:22 on Wed Feb 28 01:52:58 2024
Query failed (INSERT INTO `emhpp_sshlogs` (`user_id`, `server_id`, `serveractivity_id`, `ssh_user`, `type`, `status`, `file`, `encryption`, `mexecid`, `created`) VALUES (’49’, ’2728’, ’0’, ’root’, ’input’, ’begin’, ’/var/log/ezlogin/input/linda/root~cwh27.admod.com~Wed_Feb_28_01:53:19_2024’, ’1’, ’’, NOW())): Error 1062: Duplicate entry ’1248166’ for key ’PRIMARY’
SSH log entry (/var/log/ezlogin/input/linda/root~admod.com~Wed_Feb_28_01:53:19_2024) creation failed: 0
Step 2(A): Identify the duplicate entry in the table mentioned in the ezsh.log and log into MySQL. In this case, the duplicate entry identified by its primary key is 124866.
Step 2(B): Modify the INSERT query to include a new column called 'id', and assign it a value that is one higher than the duplicate entry shown in the ezsh.log. Make sure to replace the values for id, user_id, server_id, serveractivity_id, ssh_user, type, status, file, encryption, mexecid, and created with the actual values specific to your case.
mysql> INSERT INTO `emhpp_sshlogs` ( `id`, `user_id`, `server_id`, `serveractivity_id`, `ssh_user`, `type`, `status`, `file`, `encryption`, `mexecid`, `created`) VALUES (’1248167’, ’49’, ’2728’, ’0’, ’root’, ’input’, ’begin’, ’path_to_file’, ’1’, ’’, NOW());
Step 2(C): Delete the previously created entry from the table using a DELETE query. Replace "table_name" and "value" with the correct values. This will set the increment value correctly.
mysql> delete from table_name where id= value;
Example: mysql> delete from emhpp_sshlogs where id= 1248167;
Step 3: Once done, try logging in again to the server that previously failed during the login attempt.
For a permanent solution, the best option would be to take a database dump and then re-import it, or alternatively, update the currently used Ezeelogin to the same version.
Related Articles:
Upgrade Ezeelogin Jump server to the latest version
Basic MySQL commands for troubleshooting database related issues in Ezeelogin