Search code examples
rundeck

Rundeck user fails to switch user


Using rundeck. I created a node with the following settings:

  <attribute name="sudo-command-enabled" value="true"/>
  <attribute name="sudo-prompt-pattern" value=""/>
  <attribute name="sudo-command-pattern" value="^sudo.*"/>

I have added the key to authorized keys and made sure no password was required on the server to switch to "myuser". When I run the command to switch to "myuser" as first step in my workflow, I get the following message/output:

Sudo execution password response failed: Failed waiting for input prompt: Expected input was not seen in 5000 milliseconds
Failed: NonZeroResultCode: Remote command failed with exit status -1
myuser@<server_ip_address_here>:~$

The command run step looks like this:

sudo su - myuser

It's worth noting that manually SSH-ing into the server and typing above command yields no error whatsoever.

As can be seen in the last line, it DOES succesfully switch to "myuser". However, since the exist status is -1 it will not run any other commands following this.

What do I need to do or configure in order for my node to stop asking for the password and thus failing, especially considering the switch is apparently succesfull?


Solution

  • I did the same (passwordless sudo configuration) and works in this way.

    1. Node definition:
    <?xml version="1.0" encoding="UTF-8"?>
    <project>
      <node name="node00" 
      description="Node 00" 
      tags="user" 
      hostname="192.168.33.20" 
      osArch="amd64" 
      osFamily="unix" 
      osName="Linux" 
      osVersion="3.10.0-1062.4.1.el7.x86_64" 
      username="vagrant" 
      ssh-key-storage-path="keys/rundeck" 
      sudo-command-enabled="true" 
      sudo-command-pattern="^\[sudo\] password for .+: .*" />
    </project>
    
    1. And now you can go to the "commands" section, select the target node and switch to root user with:
    sudo whoami
    

    Now, any command with sudo statment is elevated.