Hi Russ,
Based on this and this, I did a working sudo example using OpenSSH node executor with username/password options.
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="${option.username}"
node-executor="ssh-exec"
file-copier="ssh-copier"
ssh-authentication="password"
ssh-password-option="option.password"
ssh-options="-o ConnectTimeout=5000"
sudo-command-enabled="true"
sudo-password-option="option.password"/>
</project>
And this job definition example:
<joblist>
<job>
<context>
<options preserveOrder='true'>
<option name='password' secure='true' />
<option name='username' value='vagrant' />
</options>
</context>
<defaultTab>nodes</defaultTab>
<description></description>
<dispatch>
<excludePrecedence>true</excludePrecedence>
<keepgoing>false</keepgoing>
<rankOrder>ascending</rankOrder>
<successOnEmptyNodeFilter>false</successOnEmptyNodeFilter>
<threadcount>1</threadcount>
</dispatch>
<executionEnabled>true</executionEnabled>
<id>b188c66c-c057-4bb7-98bf-7c84632bc144</id>
<loglevel>INFO</loglevel>
<name>SudoOpenSSH</name>
<nodeFilterEditable>false</nodeFilterEditable>
<nodefilters>
<filter>name: node00</filter>
</nodefilters>
<nodesSelectedByDefault>true</nodesSelectedByDefault>
<plugins />
<scheduleEnabled>true</scheduleEnabled>
<sequence keepgoing='false' strategy='node-first'>
<command>
<exec>whoami</exec>
</command>
<command>
<exec>sudo cat /etc/shadow</exec>
</command>
</sequence>
<uuid>b188c66c-c057-4bb7-98bf-7c84632bc144</uuid>
</job>
</joblist>
Hope it helps!
Has anyone gotten the OpenSSH plugin to also support sudo (with password prompt) to work with remote commands? Our basic workflow is the command would ssh as the user's personal userid and password (captured by the options in the job), step would ssh to the target node, sudo su over to target Linux userid (answering the sudo password prompt with the same password captured in the job options), and run a command.
--You received this message because you are subscribed to the Google Groups "rundeck-discuss" group.To unsubscribe from this group and stop receiving emails from it, send an email to rundeck-discu...@googlegroups.com.To view this discussion on the web visit https://groups.google.com/d/msgid/rundeck-discuss/e61ec37a-5391-4395-b4cd-ef18c993597an%40googlegroups.com.
On Feb 4, 2021, at 2:08 AM, Kobi Rosenstein <kobiros...@gmail.com> wrote:
To view this discussion on the web visit https://groups.google.com/d/msgid/rundeck-discuss/88F5180D-29EE-44AA-B379-11A2FF71193B%40getmailspring.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rundeck-discuss/befad0be-c892-429f-864e-6da809feab0dn%40googlegroups.com.
Hi Russ,
I tested using the SSHJ plugin.
1- I used a job with mypassword (to test the ssh password authentication) and sudoPassword (to test sudo) Secure Remote Authentication options:
<joblist>
<job>
<context>
<options preserveOrder='true'>
<option name='mypassword' secure='true' />
<option name='sudoPassword' secure='true' />
</options>
</context>
<defaultTab>nodes</defaultTab>
<description></description>
<dispatch>
<excludePrecedence>true</excludePrecedence>
<keepgoing>false</keepgoing>
<rankOrder>ascending</rankOrder>
<successOnEmptyNodeFilter>false</successOnEmptyNodeFilter>
<threadcount>1</threadcount>
</dispatch>
<executionEnabled>true</executionEnabled>
<id>03f28add-84f2-4013-b8f5-e48feaf5977c</id>
<loglevel>INFO</loglevel>
<name>HelloWorld</name>
<nodeFilterEditable>false</nodeFilterEditable>
<nodefilters>
<filter>name: Centos</filter>
</nodefilters>
<nodesSelectedByDefault>true</nodesSelectedByDefault>
<plugins />
<scheduleEnabled>true</scheduleEnabled>
<sequence keepgoing='false' strategy='node-first'>
<command><exec>sudo cat /etc/shadow</exec>
</command>
</sequence>
<uuid>03f28add-84f2-4013-b8f5-e48feaf5977c</uuid>
</job>
</joblist>
The detail is that the sudo password option must be named sudoPassword (defined as Secure Remote Authentication option), with another name doesn’t work.
2- My node source:
Centos:
nodename: centos
hostname: 192.168.33.20
description: centos 7
username: test
osFamily: unix
node-executor: sshj-ssh
file-copier: sshj-scp
tags: centos
ssh-authentication: password
3- I added these lines to the project.properties config:
project.sudo-command-enabled=true
project.sudo-password-option=option.sudoPassword
project.ssh-password-option=option.mypassword
Could you test in this way?
Hope it helps!