Security

Rest access to indexer from search head without password

nhalakatti_splu
Splunk Employee
Splunk Employee

I am trying to print the status and the hardware info for my indexers by executing the rest endpoint /services/server/info for each of the indexers on the search head by getting the indexer ip's from /services/search/distributed/peers endpoint. Given that the user has admin credentials and access, we can get the auth token to execute rest calls on search head using auth/login endpoint. Is there a way we can access the indexers from the search head without using the auth/login endpoint which requires indexer credentials input in the rest call. So basically if the username /password are different on indexers compared to the search head I need to keep taking the input credentials for each indexer to get the indexer information on the search head.

Is there a way to accomplish this without asking indexer credentials? or Is there a way as an admin I can get the credentials for accessing the indexers and then I can use the auth/login way?

Note: There is the trusted.pem that contains the public key of SH in SPLUNK_HOME/etc/auth/distServerKeys on the search that is distributed to indexers on adding the peer. But I believe this is more useful in SSH. Not sure if this can be used in a REST call to indexer

Tags (1)
0 Karma
1 Solution

harsmarvania57
Ultra Champion

Yes you can achieve this but it will still require you to fetch Session Key for each Indexer first on SH. When you hit /services/search/distributed/peers REST endpoint on SH, you will get list of all Indexers and for each Indexer there is remote_session which is Session Key.

So you can use that remote_session in curl as given below

curl -k -H "Authorization: Splunk INDEXER_REMOTE_SESSION_KEY" https://<indexer_host_ip>:8089/services/server/info

View solution in original post

harsmarvania57
Ultra Champion

Yes you can achieve this but it will still require you to fetch Session Key for each Indexer first on SH. When you hit /services/search/distributed/peers REST endpoint on SH, you will get list of all Indexers and for each Indexer there is remote_session which is Session Key.

So you can use that remote_session in curl as given below

curl -k -H "Authorization: Splunk INDEXER_REMOTE_SESSION_KEY" https://<indexer_host_ip>:8089/services/server/info

nhalakatti_splu
Splunk Employee
Splunk Employee

Thanks @harsmarvania57 ! This does the trick!

0 Karma

somesoni2
Revered Legend

You do this via | rest search command or using curl (or any other rest tool)?

0 Karma

nhalakatti_splu
Splunk Employee
Splunk Employee

curl like mechanism

0 Karma
Get Updates on the Splunk Community!

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...