Splunk API not working with cURL using port 8000 - bash

I'm trying to login on my local Splunk server using curl bash command but without success, so far I have tried the following:
curl -u admin:changeme -k http://192.168.1.103:8000/en-US/account/login
curl -u admin:changeme -k http://192.168.1.103:8000/en-US/account/login -d"username=admin&password=changeme"
Any help would be very appreciated,
Thanks.

Are you trying to do REST calls? You need to hit port 8089

Related

How to use Ambari API to Update Configs with a file

So you can't directly update a single item, but must get the entire config group associated with.
What I have done is:
# read the tag of target config i want
curl -u $USERNAME:$PASSWORD -H "X-Requested-By: ambari" -X GET $BASE_URI?fields=Clusters/desired_configs > .temp_json
# download my configs
curl -u $USERNAME:$PASSWORD -H "X-Requested-By: ambari" -X GET "$BASE_URI/configurations?type=$CONFIG_TYPE&tag=$TARGET_TAG" > .configs_to_update
# update configs here > UPDATED_FILE_HERE
# ??? (upload the configs)
The next step is to upload the configs to the server then restart the services. I can't seem to figure out the API call to upload the configs. Does anyone know how I can upload the configs with the Ambari REST API?
I am not sure if this helps your situation, but check out this command I use to make an adjustment to a single config:
python /var/lib/ambari-server/resources/scripts/configs.py -u admin -p admin -n HDP3 -l c7404.ambari.apache.org -t 8080 -a set -c cluster-env -k ignore_groupsusers_create -v true

Curl HTTPS returns empty string, how to set CURLOPT_SSL_VERIFYHOST in Linux shell / bash script

I have simple shell script that uses curl to get a response from a remote URL. The issue is that I migrated the said URL to HTTPS and now curl return an empty string. It seems that setting CURLOPT_SSL_VERIFYHOST option should fix the issue but how do I set this option in a shell script? Any other options / workarounds?
#! /bin/bash
URL=$(curl -u user:pass -A "Mozilla" https://example.com/ddns/update.php)
Today, I happened to have the same issue. neither -k and --insecure nor -L worked, but then for some reason I mixed them and it worked.
I can't say why that happened, but this worked for me:
curl -kL https://...
PS: it was a Jupyter notebook server. my guess is that it uses both ssl and redirection.

Send email via curl

I try to send a email via curl. and the following code dosen't work.
curl --connect-timeout 59 -v --insecure "smtps://smtp.live.com:25" -u "*****#outlook.com:*******" --mail-from "********#outlook.com" --mail-rcpt "*****#yahoo.de" -T mail.txt --ssl
Can someone tell me whats wrong? I wanna send the email via Outlook.com.
After you have added more detailed output , it looks like ssl related issue, the same symptoms are described here - cURL: Operation timed out after 0 milliseconds , hopefully this helps.

Different body for same Curl request sent from Windows and Ubuntu

I'm trying to send a curl request from both Windows and Ubuntu system to a Rest API. following is the request
curl -k -X POST http://172.16.76.1:8080/test -d 'sample_param={"user_info":{"name":"abc","age":"20"}}'
When I read this from the server side, I get the following two different content data from each OS
Body for curl request from Ubuntu:
sample_param={"user_info":{"name":"abc","age":"20"}}
Body for curl request from Windows:
sample_param={user_info:{name:abc,age:20}}
(Note that double quotations are missing)
As a result I cannot get the json object from the request.
Can someone point out the mistake and give a solution for this.
Thanks in advance
Changing the curl command to following worked
curl -k -X POST http://172.16.76.1:8080/test -d "sample_param={\"user_info\":{\"name\":\"abc\",\"age\":\"20\"}}"

How to debug a ssh tunnel

I want to setup a simple ssh tunnel from a local machine to a machine on the internet.
I'm using
ssh -D 8080 -f -C -q -N -p 12122 <username>#<hostname>
Setup works fine (I think) cause ssh returs asking for the credentials, which I provide.
Then i do
export http_proxy=http://localhost:8080
and
wget http://www.google.com
Wget returns that the request has been sent to the proxy, but no data is received back.
What i need is a way to look at how ssh is processing the request....
To get more information out of your SSH connection for debugging, leave out the -q and -f options, and include -vvv:
ssh -D 8080 -vvv -N -p 12122 <username>#<hostname>
To address your actual problem, by using ssh -D you're essentially setting up a SOCKS proxy which I believe is not supported by default in wget.
You might have better luck with curl which provides SOCKS suport via the --socks option.
If you really really need to use wget, you'll have to recompile your own version to include socks support. There should be an option for ./configure somewhere along the lines of --with-socks.
Alternatively, look into tsock which can intercept outgoing network connections and redirecting them through a SOCKS server.

Resources