SSH-key authentication and enabling alias

From PheonixSolutions
Jump to navigation Jump to search

Step:1 Login to nagios like as usual

 ssh user@ip -p7102

Step:2 As a root user run the below command to add nagios key to the required server (to login without password)

 ssh-copy-id pheonix@requiredip -p7102

Provide the required password

Step:3

Login to a required/remote server with pheonix user

Note: if you are not confident please take the backup for the files which you will go to modify

Step:4

Edit the sudoers file

vi /etc/sudoers

Step:5

Copy and paste the below line under the section #includedir /etc/sudoers.d (it will be at the end of the file) - this is to avoid entering the password while doing sudo su

pheonix ALL=(ALL) NOPASSWD: ALL

Note: remove # before the pheonix ALL=(ALL) NOPASSWD: ALL

Snapshot for ref.

Step:6

Save and Exit the file, the remote server

Step:7

In nagios under root user

 cd /root
vi .bashrc

Copy and paste the below line. Modify the ip and name accordingly without adding space

 alias name='ssh pheonix@ip -p7102'

Snapshot for ref.

Step:8

Then Run the below command

source ~/.bashrc

Step:9

Then try to login with the alias name, we should able to login with password and IP address