Configure Automatic su or sudo

How to configure Automatic su or sudo /switch user CentOS/Freebsd/Ubuntu servers?

 check out the following video to ensure that you have configured the auto login correctly

 

1. Ensure that the remote ssh user has the bash shell enabled.


The finger command would let you know the currently assigned shell for the remote ssh user.

finger devops

Login: devops Name: devops

Directory: /home/devops Shell: /usr/local/bin/tsh


You may assigned bash shell to the user using the command

chsh -s /usr/local/bin/bash devops


2. You would now need to identify the 'First Prompt' , to find it, login as the ssh user and you will get the prompts

  In this case the 'first prompt' would be '$% '. 

There is the space character included as well so totally there a 3 characters as required.


3. Now if you are switching to root user using sudo, then you would need to 'enable sudo' and enter the 'root prompt' field.

  In this case the 'Root Prompt' would be ']#

There is the space character included as well so totally there a 3 characters as required.


4. once you fill in the 'first prompt' and 'root prompt' then you need to take a look at the 'Password Prompt' variable.

[email protected]:~$% sudo su -

[sudo] password for devops:



The 'Password Prompt' would be '[sudo] password for devops:'

One you have filled in all the three variables, automatic sudo would work.

If you are using su instead of sudo to switch as root then you need not enter the 'root prompt' and should disable sudo.

Also you would need to enter the field 'Switch User' and 'Switch User Password' 'Switch User' would be 'root' and the 'Switch User Password' would be the root password.

0 (0)
Article Rating (No Votes)
Rate this article
    Attached Files
    There are no attachments for this article.