I have written icinga configuration file for some servers to monitoring it. In that, some custom scripts are running with SSH command to monitor the Server status. Everything goes fine till when did shut down the server and launch the same server ( same hostname ) with different hardware due to Memory problem.
Note : Memory problem - Sometimes, We need better RAM and Harddisk to handle the traffic when server started to get more request from the Client.
In this moment, the icinga custom scripts and inbuild scripts that related to the server hostname are started to throw the error message that can't connect to server using SSH : SSH Failed ( Same host name. But different hardware ). Because, My monitor server has Old server SSH Key in Known_Hosts for hostname. But, My monitoring server was trying to connect to New Server with Old server SSH Key from Known_Hosts.
To avoid this problem, We need to remove Old Server SSH Key belong with Hostname from Known_Hosts using SSH Command ( Refer SSH --help or man SSH or I will update the exact command sometime later ).
I am sure, You people are little confused about above statement. Why this guy telling about these stuff and How this article title should be related to above statement ?. Let me clear you questions below
I hope you people able to understand the above situation that happened to me. Usually, We need to share both server's SSH Public key to do SSH. Here I was sharing my server SSH Public key with Nagios user to other servers. Hence I have to do SSH from My Server to Other server by manually as Nagios user to overcome the above problem. This makes the Icinga custom scripts and Inbuild scripts for the server will run without any issue.
But I didn't know, How to Login as Nagios user in terminal to do SSH Manually. After spent a long time, I have found the below steps.
Step 1 : Launch the terminal
Step 2 : Execute the following commands,
sudo vim /etc/passwd
Note : You can use some other text editor if you want
In passwd file, nagios should be with /sbin/nologin
So you should replace /sbin/nologin with /bin/bash
Step 3 : Save the changes in passwd file
Step 4 : Execute this command in the terminal
sudo su nagios
Now you can successfully login into nagios user and do whatever you want in it.
I hope this should be helpful to you. Please leave a comment if you have any suggestion about this article.
Comments
Post a Comment