<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: splunk add user non-interactive without logging in on command line in Security</title>
    <link>https://community.splunk.com/t5/Security/splunk-add-user-non-interactive-without-logging-in-on-command/m-p/108543#M3498</link>
    <description>&lt;P&gt;I had this problem whilst using puppet to provision my servers. I found that Example42's &lt;A href="https://github.com/example42/puppet-splunk"&gt;puppet module for Splunk&lt;/A&gt; solved it for me.&lt;/P&gt;</description>
    <pubDate>Sat, 10 Aug 2013 00:51:53 GMT</pubDate>
    <dc:creator>devs</dc:creator>
    <dc:date>2013-08-10T00:51:53Z</dc:date>
    <item>
      <title>splunk add user non-interactive without logging in on command line</title>
      <link>https://community.splunk.com/t5/Security/splunk-add-user-non-interactive-without-logging-in-on-command/m-p/108533#M3488</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I am writing some scripts to manage the users on our Splunk environment. The scripts should be invoke in non-interactive mode from within another tool used for managing users in our company.&lt;/P&gt;

&lt;P&gt;The problem is that "splunk add user" or "splunk edit user" on command line require logging in with an existing user with admin privileges. They ask about username/password.&lt;/P&gt;

&lt;P&gt;I know I could write something in "expect" or modify the splunk passwd file all by myself with the script but that's somehow too much overhead in my opinion.&lt;/P&gt;

&lt;P&gt;Is there a way to make it non-iteractive or to save the credentials in some file or to allow "splunk..." commands without password from the command line of the same server??&lt;/P&gt;

&lt;P&gt;Reagards,
Bartosz&lt;/P&gt;</description>
      <pubDate>Thu, 23 Dec 2010 23:14:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Security/splunk-add-user-non-interactive-without-logging-in-on-command/m-p/108533#M3488</guid>
      <dc:creator>tzhmaba2</dc:creator>
      <dc:date>2010-12-23T23:14:13Z</dc:date>
    </item>
    <item>
      <title>Re: splunk add user non-interactive without logging in on command line</title>
      <link>https://community.splunk.com/t5/Security/splunk-add-user-non-interactive-without-logging-in-on-command/m-p/108534#M3489</link>
      <description>&lt;P&gt;This is how I managed to get a non-interactive way to work with splunk with the root user:&lt;/P&gt;

&lt;P&gt;I've added a new user to Splunk called cli with a long random password.&lt;/P&gt;

&lt;P&gt;Then I created a file /root/.splunk-cli-credentials with the password as content&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;echo "mySecretPassword " &amp;gt; /root/.splunk-cli-credentials
chmod 600 /root/.splunk-cli-credentials
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;and added the following entry to my /root/.bashrc:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;alias xsplunk="splunk login -auth 'cli:$(cat /root/.splunk-cli-credentials)' &amp;amp;&amp;amp; splunk"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This lets me use the xsplunk command without logging in each time:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;xsplunk add user test -password bar -role user
xsplunk search "sourcetype=foo"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 23 Dec 2010 23:34:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Security/splunk-add-user-non-interactive-without-logging-in-on-command/m-p/108534#M3489</guid>
      <dc:creator>ziegfried</dc:creator>
      <dc:date>2010-12-23T23:34:29Z</dc:date>
    </item>
    <item>
      <title>Re: splunk add user non-interactive without logging in on command line</title>
      <link>https://community.splunk.com/t5/Security/splunk-add-user-non-interactive-without-logging-in-on-command/m-p/108535#M3490</link>
      <description>&lt;P&gt;I would of preferred not to use the alias approach, since I'd have to monkey with root bashrc stuff on a box that i don't directly have linux ownership of. But i could not get embedding  'cli:$(cat /root/.splunk-cli-credentials)' in the cron.monthly script to work. Some special alias magic that my bash skills are not up to figuring out&lt;/P&gt;</description>
      <pubDate>Wed, 29 Dec 2010 07:02:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Security/splunk-add-user-non-interactive-without-logging-in-on-command/m-p/108535#M3490</guid>
      <dc:creator>freeti00</dc:creator>
      <dc:date>2010-12-29T07:02:13Z</dc:date>
    </item>
    <item>
      <title>Re: splunk add user non-interactive without logging in on command line</title>
      <link>https://community.splunk.com/t5/Security/splunk-add-user-non-interactive-without-logging-in-on-command/m-p/108536#M3491</link>
      <description>&lt;P&gt;I would recommend using a scripted input and the Splunk REST API.  Scripted inputs, configured via inputs.conf, can be passed a valid authentication token via STDIN if the passAuth= option is included.  This auth token can be used to authenticate to the REST API and perform tasks such as adding or editing users.&lt;/P&gt;</description>
      <pubDate>Wed, 29 Dec 2010 07:31:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Security/splunk-add-user-non-interactive-without-logging-in-on-command/m-p/108536#M3491</guid>
      <dc:creator>araitz</dc:creator>
      <dc:date>2010-12-29T07:31:33Z</dc:date>
    </item>
    <item>
      <title>Re: splunk add user non-interactive without logging in on command line</title>
      <link>https://community.splunk.com/t5/Security/splunk-add-user-non-interactive-without-logging-in-on-command/m-p/108537#M3492</link>
      <description>&lt;P&gt;I used shopts -s expand_aliases in the script and its working now.&lt;/P&gt;</description>
      <pubDate>Wed, 29 Dec 2010 07:34:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Security/splunk-add-user-non-interactive-without-logging-in-on-command/m-p/108537#M3492</guid>
      <dc:creator>freeti00</dc:creator>
      <dc:date>2010-12-29T07:34:24Z</dc:date>
    </item>
    <item>
      <title>Re: splunk add user non-interactive without logging in on command line</title>
      <link>https://community.splunk.com/t5/Security/splunk-add-user-non-interactive-without-logging-in-on-command/m-p/108538#M3493</link>
      <description>&lt;P&gt;The "cat file" works perfect for me. Just what I needed. However the password is still stored somewhere and accessible one way ot another.&lt;/P&gt;

&lt;P&gt;Thanks!!&lt;/P&gt;</description>
      <pubDate>Wed, 29 Dec 2010 20:51:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Security/splunk-add-user-non-interactive-without-logging-in-on-command/m-p/108538#M3493</guid>
      <dc:creator>tzhmaba2</dc:creator>
      <dc:date>2010-12-29T20:51:22Z</dc:date>
    </item>
    <item>
      <title>Re: splunk add user non-interactive without logging in on command line</title>
      <link>https://community.splunk.com/t5/Security/splunk-add-user-non-interactive-without-logging-in-on-command/m-p/108539#M3494</link>
      <description>&lt;P&gt;Sounds like magic to me at the moment. &lt;span class="lia-unicode-emoji" title=":grinning_face_with_smiling_eyes:"&gt;😄&lt;/span&gt; I would probably have to spend a week to learn the API first and stuff about some auth tokens to do a trivial task. The "cat file" sollution is fine for me ATM. Thanks anyway. Will probably have to struggle with API anyway later...&lt;/P&gt;</description>
      <pubDate>Wed, 29 Dec 2010 20:53:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Security/splunk-add-user-non-interactive-without-logging-in-on-command/m-p/108539#M3494</guid>
      <dc:creator>tzhmaba2</dc:creator>
      <dc:date>2010-12-29T20:53:10Z</dc:date>
    </item>
    <item>
      <title>Re: splunk add user non-interactive without logging in on command line</title>
      <link>https://community.splunk.com/t5/Security/splunk-add-user-non-interactive-without-logging-in-on-command/m-p/108540#M3495</link>
      <description>&lt;P&gt;Yes, but only for the root user.&lt;/P&gt;</description>
      <pubDate>Wed, 29 Dec 2010 21:57:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Security/splunk-add-user-non-interactive-without-logging-in-on-command/m-p/108540#M3495</guid>
      <dc:creator>ziegfried</dc:creator>
      <dc:date>2010-12-29T21:57:19Z</dc:date>
    </item>
    <item>
      <title>Re: splunk add user non-interactive without logging in on command line</title>
      <link>https://community.splunk.com/t5/Security/splunk-add-user-non-interactive-without-logging-in-on-command/m-p/108541#M3496</link>
      <description>&lt;P&gt;Hi again,&lt;/P&gt;

&lt;P&gt;I've got another problem now. My script is getting the password as an MD5 hash on input. As far as I understand the "splunk add user -password" expects cleartext password. So I am creating the user woth any password first and then I am editing the /opt/splunk/etc/passwd with a PERL script to put the MD5 hash in. But I have discovered that as soon as you edit the "passwd" file by other means than the splunk command you cannot log in (via "splunk login" or via web interface). It just says incorrect username. As if the "splunk" command did some hidden stuff which my PERL does not.&lt;/P&gt;</description>
      <pubDate>Wed, 29 Dec 2010 23:20:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Security/splunk-add-user-non-interactive-without-logging-in-on-command/m-p/108541#M3496</guid>
      <dc:creator>tzhmaba2</dc:creator>
      <dc:date>2010-12-29T23:20:02Z</dc:date>
    </item>
    <item>
      <title>Re: splunk add user non-interactive without logging in on command line</title>
      <link>https://community.splunk.com/t5/Security/splunk-add-user-non-interactive-without-logging-in-on-command/m-p/108542#M3497</link>
      <description>&lt;P&gt;Has anyone any idea what am I missing? What does the "splunk" command do what my scripts don't? Or should I slowly start looking at the API? &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;Thanks in advance for any clues.&lt;/P&gt;

&lt;P&gt;Bartosz&lt;/P&gt;</description>
      <pubDate>Wed, 29 Dec 2010 23:21:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Security/splunk-add-user-non-interactive-without-logging-in-on-command/m-p/108542#M3497</guid>
      <dc:creator>tzhmaba2</dc:creator>
      <dc:date>2010-12-29T23:21:07Z</dc:date>
    </item>
    <item>
      <title>Re: splunk add user non-interactive without logging in on command line</title>
      <link>https://community.splunk.com/t5/Security/splunk-add-user-non-interactive-without-logging-in-on-command/m-p/108543#M3498</link>
      <description>&lt;P&gt;I had this problem whilst using puppet to provision my servers. I found that Example42's &lt;A href="https://github.com/example42/puppet-splunk"&gt;puppet module for Splunk&lt;/A&gt; solved it for me.&lt;/P&gt;</description>
      <pubDate>Sat, 10 Aug 2013 00:51:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Security/splunk-add-user-non-interactive-without-logging-in-on-command/m-p/108543#M3498</guid>
      <dc:creator>devs</dc:creator>
      <dc:date>2013-08-10T00:51:53Z</dc:date>
    </item>
    <item>
      <title>Re: splunk add user non-interactive without logging in on command line</title>
      <link>https://community.splunk.com/t5/Security/splunk-add-user-non-interactive-without-logging-in-on-command/m-p/108544#M3499</link>
      <description>&lt;P&gt;Thanks for the tips.  I played around with passing variables to Splunk CLI using the examples you had in this post and was able to change passwords w/o exposing the password on the screen or storing the password in a file.&lt;/P&gt;

&lt;P&gt;'#!/bin/bash&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;    read -sp "Enter Current Password: " currPass
    echo
    read -sp "Enter New Password: " newPass
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;/opt/splunk/bin/splunk edit user john -password $(echo $newPass) -auth john:$(echo $currPass)'&lt;/P&gt;</description>
      <pubDate>Mon, 11 Feb 2019 23:43:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Security/splunk-add-user-non-interactive-without-logging-in-on-command/m-p/108544#M3499</guid>
      <dc:creator>john_w_shields</dc:creator>
      <dc:date>2019-02-11T23:43:33Z</dc:date>
    </item>
  </channel>
</rss>

