Resolve the problem of no sudo permissions when adding a host

2023-08-15 02:30:56  Updated

Description

After you select a credential on the Add Host page, the system prompts that "The credential has no sudo permissions."

Possible causes

  • The host to be added is not initialized.

  • A common user is used to add the host. You need to configure the common user to gain the sudo permissions without the password.

  • The sudoer file is incorrectly configured.

Solutions

  1. Check whether the host is initialized.

    You need to initialize the host before adding it. For more information, see Initialize a server.

  2. Make sure that you are logged on as the root user when you add a host.

    • Otherwise, the logged on user must have the permission to run sudo commands without specifying the password. The procedure is described by taking a test user as an example.

      1. Log on to the target host to be added as the root user.

      2. Run the vi /etc/sudoers command to access the sudoers file.

      3. Make the following modifications on this file.

        Add a row test ALL=(ALL) NOPASSWD:ALL and add comments Defaults requiretty and Defaults !visiblepw.

        ## Allow root to run any commands anywhere
        root  ALL=(ALL)       ALL
        root  ALL=(ALL) NOPASSWD:ALL
        
        
        test  ALL=(ALL) NOPASSWD:ALL 
        # Defaults !visiblepw
        # Defaults requiretty
        
    • If you are logged on as the root user, find the sudoers file of the target host in the /etc/ directory and add comments Defaults requireretty and Defaults !visiblepw.

  3. Check for other possible causes.

    Run the ssh 192.168.01.1 'sudo -n true; echo $?' command, where 192.168.0.1 is the IP address of the target host to be added. Enter the password to view the returned information.

    • If the returned information is sudo: sorry, you must have a tty to tun sudo.

      Find the sudoers file of the target host in the /etc/ directory and add comments Defaults requireretty and Defaults !visiblepw.

    • If other information is returned, further analysis is required.

  4. If you cannot locate the cause, send the ocp.log file to OCP technical support.

Contact Us