<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<atom:link href="http://dev1galaxy.org/extern.php?action=feed&amp;tid=3089&amp;type=rss" rel="self" type="application/rss+xml" />
		<title><![CDATA[Dev1 Galaxy Forum / Unable to ssh from A to B to execute sudo command with arguments]]></title>
		<link>http://dev1galaxy.org/viewtopic.php?id=3089</link>
		<description><![CDATA[The most recent posts in Unable to ssh from A to B to execute sudo command with arguments.]]></description>
		<lastBuildDate>Wed, 02 Oct 2019 16:39:08 +0000</lastBuildDate>
		<generator>FluxBB</generator>
		<item>
			<title><![CDATA[Re: Unable to ssh from A to B to execute sudo command with arguments]]></title>
			<link>http://dev1galaxy.org/viewtopic.php?pid=18136#p18136</link>
			<description><![CDATA[<div class="quotebox"><cite>chris2be8 wrote:</cite><blockquote><div><p>I&#039;ve not used sudo for passwordless access for quite a few years. But as far as I can remember:<br />Start by running <span class="bbc">sudo -l</span> on wolke7 and see what it says you can do.</p></div></blockquote></div><p>Thank you, please see:</p><div class="codebox"><pre><code>os@wolke7:~$ sudo -l
Matching Defaults entries for os on wolke7:
    env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin

User os may run the following commands on wolke7:
    (root) NOPASSWD: /sbin/wondershaper *
    (ALL : ALL) ALL
os@wolke7:~$ sudo /sbin/wondershaper eth0 125 125
[sudo] password for os: 
Sorry, try again.
[sudo] password for os: </code></pre></div><p>So sudo is not working for me. </p><p>If I redo the change to <strong>/etc/pam.d/sudo</strong> as described the link in the first post, it works as expected.<br />Is by chance /etc/pam.d/sudo broken in Devuan ASCII?</p><p>Thanks, -MN</p>]]></description>
			<author><![CDATA[dummy@example.com (Morgennebel)]]></author>
			<pubDate>Wed, 02 Oct 2019 16:39:08 +0000</pubDate>
			<guid>http://dev1galaxy.org/viewtopic.php?pid=18136#p18136</guid>
		</item>
		<item>
			<title><![CDATA[Re: Unable to ssh from A to B to execute sudo command with arguments]]></title>
			<link>http://dev1galaxy.org/viewtopic.php?pid=18135#p18135</link>
			<description><![CDATA[<p>Thank you,</p><p>I changed back the /etc/pam.d/sudo to original version:</p><div class="codebox"><pre><code>root@wolke7:~# cat /etc/pam.d/sudo
#%PAM-1.0

@include common-auth
@include common-account
@include common-session-noninteractive</code></pre></div><p>and adopted your proposal:</p><div class="codebox"><pre class="vscroll"><code>root@wolke7:~# cat /etc/sudoers
#
# This file MUST be edited with the &#039;visudo&#039; command as root.
#
# Please consider adding local content in /etc/sudoers.d/ instead of
# directly modifying this file.
#
# See the man page for details on how to write a sudoers file.
#
Defaults	env_reset
Defaults	mail_badpass
Defaults	secure_path=&quot;/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin&quot;

# Host alias specification

# User alias specification

# Cmnd alias specification

# User privilege specification
root	ALL=(ALL:ALL) ALL
#os	ALL=(ALL) NOPASSWD:  /sbin/wondershaper eth0 *
#os	ALL=(root) NOPASSWD: /bin/echo foo
os	ALL= NOPASSWD: /sbin/wondershaper

# Allow members of group sudo to execute any command
%sudo	ALL=(ALL:ALL) ALL

# See sudoers(5) for more information on &quot;#include&quot; directives:

#includedir /etc/sudoers.d</code></pre></div><p>As you can see, the two other lines are commented out.</p><p>After a reboot, sudo does not work:</p><div class="codebox"><pre><code>os@wolke7:~$ sudo /sbin/wondershaper eth0 125 125
[sudo] password for os: 
Sorry, try again.
[sudo] password for os: </code></pre></div><p>And in /var/log/auth.log I do see:</p><div class="codebox"><pre><code>Oct  2 18:31:52 wolke7 su[2021]: pam_unix(su:session): session closed for user root
Oct  2 18:31:56 wolke7 sudo: pam_unix(sudo:auth): authentication failure; logname=os uid=1000 euid=0 tty=/dev/pts/0 ruser=os rhost=  user=os
Oct  2 18:32:22 wolke7 sudo: pam_unix(sudo:auth): conversation failed
Oct  2 18:32:22 wolke7 sudo: pam_unix(sudo:auth): auth could not identify password for [os]
Oct  2 18:32:22 wolke7 sudo:       os : 1 incorrect password attempt ; TTY=pts/0 ; PWD=/home/os ; USER=root ; COMMAND=/sbin/wondershaper eth0 125 125
Oct  2 18:32:32 wolke7 su[2060]: Successful su for root by os
Oct  2 18:32:32 wolke7 su[2060]: + /dev/pts/0 os:root
Oct  2 18:32:32 wolke7 su[2060]: pam_unix(su:session): session opened for user root by os(uid=1000)
Oct  2 18:32:32 wolke7 su[2060]: pam_elogind(su:session): Cannot create session: Already running in a session
Oct  2 18:32:53 wolke7 su[2060]: pam_unix(su:session): session closed for user root
Oct  2 18:32:55 wolke7 sudo: pam_unix(sudo:auth): conversation failed
Oct  2 18:32:55 wolke7 sudo: pam_unix(sudo:auth): auth could not identify password for [os]
Oct  2 18:33:03 wolke7 su[2088]: Successful su for root by os
Oct  2 18:33:03 wolke7 su[2088]: + /dev/pts/0 os:root
Oct  2 18:33:03 wolke7 su[2088]: pam_unix(su:session): session opened for user root by os(uid=1000)
Oct  2 18:33:03 wolke7 su[2088]: pam_elogind(su:session): Cannot create session: Already running in a session</code></pre></div><p>Even when adding a * to <strong>os&#160; &#160; ALL= NOPASSWD: /sbin/wondershaper</strong> at the end to indicate arguments to wondershaper, it does not work.</p><p>/me confused.</p><p>Thanks, -MN</p>]]></description>
			<author><![CDATA[dummy@example.com (Morgennebel)]]></author>
			<pubDate>Wed, 02 Oct 2019 16:36:44 +0000</pubDate>
			<guid>http://dev1galaxy.org/viewtopic.php?pid=18135#p18135</guid>
		</item>
		<item>
			<title><![CDATA[Re: Unable to ssh from A to B to execute sudo command with arguments]]></title>
			<link>http://dev1galaxy.org/viewtopic.php?pid=18134#p18134</link>
			<description><![CDATA[<p>I&#039;ve not used sudo for passwordless access for quite a few years. But as far as I can remember:</p><p>It should not make any difference whether you logged onto wolke7 through ssh or directly on to it.</p><p>Start by running <span class="bbc">sudo -l</span> on wolke7 and see what it says you can do.</p><p>Once you can run it locally without being asked for a password <span class="bbc">ssh os@192.168.255.42 &#039;/sbin/wondershaper eth0 1500 750&#039;</span> should work.</p><p>Chris</p>]]></description>
			<author><![CDATA[dummy@example.com (chris2be8)]]></author>
			<pubDate>Wed, 02 Oct 2019 16:29:27 +0000</pubDate>
			<guid>http://dev1galaxy.org/viewtopic.php?pid=18134#p18134</guid>
		</item>
		<item>
			<title><![CDATA[Re: Unable to ssh from A to B to execute sudo command with arguments]]></title>
			<link>http://dev1galaxy.org/viewtopic.php?pid=18133#p18133</link>
			<description><![CDATA[<p>I&#039;m no sudo expert, but you shouldn&#039;t have to mess with pam to allow a user to have certain commands with no password. First thing I would try is to just list the command with its full path but without the arguments. And maybe leave out the (ALL).</p><p>Maybe this:</p><div class="codebox"><pre><code>os      ALL= NOPASSWD:  /sbin/wondershaper</code></pre></div>]]></description>
			<author><![CDATA[dummy@example.com (fsmithred)]]></author>
			<pubDate>Wed, 02 Oct 2019 16:12:04 +0000</pubDate>
			<guid>http://dev1galaxy.org/viewtopic.php?pid=18133#p18133</guid>
		</item>
		<item>
			<title><![CDATA[Unable to ssh from A to B to execute sudo command with arguments]]></title>
			<link>http://dev1galaxy.org/viewtopic.php?pid=18132#p18132</link>
			<description><![CDATA[<p>Dear,</p><p>I have system A with userA and system B with userB. Both systems run Devuan ASCII with all updates.</p><p>My challenge: I need to ssh userA@A to userB@B without a password to execute a command (wondershaper) which requires sudo rights.</p><p>My steps:</p><ul><li><p>I enabled password-less ssh from userA@A to userB@B which works fine</p></li><li><p>I modified /etc/sudoers on B to allow userB@B to execute wondershaper without password</p></li></ul><p>Logs passwordless-ssh:</p><div class="codebox"><pre><code>fhem@smarthome:~$ 
fhem@smarthome:~$ ssh os@192.168.255.42
Linux wolke7 4.9.0-6-amd64 x86_64 GNU/Linux

The programs included with the Devuan GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Devuan GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Tue Oct  1 18:48:20 2019 from 192.168.255.100
os@wolke7:~$ </code></pre></div><p>The command to be executed from userB@B is /sbin/wondershaper with 3 arguments (Network device, Downspeed, Upspeed).</p><p>My /etc/sudoers (edited with visudo) on system B is</p><div class="codebox"><pre class="vscroll"><code>#
# This file MUST be edited with the &#039;visudo&#039; command as root.
#
# Please consider adding local content in /etc/sudoers.d/ instead of
# directly modifying this file.
#
# See the man page for details on how to write a sudoers file.
#
Defaults        env_reset
Defaults        mail_badpass
Defaults        secure_path=&quot;/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin&quot;

# Host alias specification

# User alias specification

# Cmnd alias specification

# User privilege specification
root    ALL=(ALL:ALL) ALL
os      ALL=(ALL) NOPASSWD:  /sbin/wondershaper eth0 *
os      ALL=(root) NOPASSWD: /bin/echo foo

# Allow members of group sudo to execute any command
%sudo   ALL=(ALL:ALL) ALL

# See sudoers(5) for more information on &quot;#include&quot; directives:

#includedir /etc/sudoers.d</code></pre></div><p>With this setup userB (= os) should be able to sudo without a password /sbin/wondershaper eth0 with two additional parameters.</p><p>However sudo is asking for the user password:</p><div class="codebox"><pre><code>os@wolke7:~$ 
os@wolke7:~$ 
os@wolke7:~$ sudo /sbin/wondershaper eth0 1500 750
[sudo] password for os: </code></pre></div><p>Logfile /var/log/auth.log reports:</p><div class="codebox"><pre><code>Oct  2 15:17:01 wolke7 CRON[16018]: pam_unix(cron:session): session closed for user root
Oct  2 15:18:42 wolke7 su[16008]: pam_unix(su:session): session closed for user root
Oct  2 15:19:13 wolke7 sudo: pam_unix(sudo:auth): conversation failed
Oct  2 15:19:13 wolke7 sudo: pam_unix(sudo:auth): auth could not identify password for [os]
Oct  2 15:19:36 wolke7 sudo: pam_unix(sudo:auth): conversation failed
Oct  2 15:19:36 wolke7 sudo: pam_unix(sudo:auth): auth could not identify password for [os]
Oct  2 15:19:43 wolke7 su[16054]: Successful su for root by os
Oct  2 15:19:43 wolke7 su[16054]: + /dev/pts/1 os:root
Oct  2 15:19:43 wolke7 su[16054]: pam_unix(su:session): session opened for user root by os(uid=1000)
Oct  2 15:19:43 wolke7 su[16054]: pam_elogind(su:session): Cannot create session: Already running in a session</code></pre></div><p>To read the logfile I used &quot;su -&quot; as userB on system B.</p><p>I found <a href="https://stackoverflow.com/questions/57657645/pam-unixsudoauth-conversation-failed-auth-could-not-identify-password-for" rel="nofollow">https://stackoverflow.com/questions/576 … ssword-for</a> as potential solution which is to change /etc/pam.d/sudo . The Poster has the same challenge on a CentOS 7 system. The /etc/pam.d/sudo file looks similiar on my Devuan ASCII system missing lines like</p><div class="codebox"><pre><code># Fixing ssh &quot;auth could not identify password for [username]&quot;
auth       sufficient   pam_permit.so</code></pre></div><p>I have very little to no experience configuring pam - is this the right solution for Devuan as well?</p><p>Thanks, -MN</p>]]></description>
			<author><![CDATA[dummy@example.com (Morgennebel)]]></author>
			<pubDate>Wed, 02 Oct 2019 13:26:35 +0000</pubDate>
			<guid>http://dev1galaxy.org/viewtopic.php?pid=18132#p18132</guid>
		</item>
	</channel>
</rss>
