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.

root@ec2:~$% 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.
    Related Articles RSS Feed
    vzctl enter veid fails. Unable to get term attr: Invalid argument
    Viewed 3048 times since Wed, Jun 14, 2017
    User add failed
    Viewed 4430 times since Wed, Jun 14, 2017
    Unable to add server into Ezeelogin via webinterface. Password error, times out
    Viewed 2468 times since Wed, Jun 14, 2017
    getting config from other node failed
    Viewed 997 times since Wed, Jan 9, 2019
    Viewed 6044 times since Fri, Feb 2, 2018
    404 error on login with nginx
    Viewed 3931 times since Wed, Jun 14, 2017
    strange characters in the SSH logs recordings
    Viewed 2781 times since Thu, Jun 15, 2017
    ERROR for site owner: Invalid domain for site key
    Viewed 6690 times since Thu, Jun 28, 2018
    User could not be found on the system:: No error information
    Viewed 886 times since Thu, May 30, 2019
    Unable to login into cpanel/whm with one click
    Viewed 6749 times since Wed, Jun 14, 2017