How to get a token from a ElasticSearch server? - elasticsearch

I am trying to connect kibana to an elasticsearch server, where the username is "elastic", which means I cannot use the user and password to connect to the server, I have to use a token.
I tried to run command curl -H "Authorization: Bearer dGhpcyBpcyBub3Qx5...F0YS4gZG8gbm90IHRyeSB0byByZWFkIHRva2VuIQ==" http://localhost:9200
However, this doesn't work, the error message says I did not provide enough credentials, which makes sense since this server is password protected.
And then I tried to run the command curl -H "Authorization: Bearer dGhpcyBpcyBub3Qx5...F0YS4gZG8gbm90IHRyeSB0byByZWFkIHRva2VuIQ==" http://localhost:9200 -u elastic:password, but it still doesn't work and tells me the command syntax is wrong.
What should I do?

Related

curl pull request error - fork_collab Fork collab can't be granted by someone without permission

I'm trying to automate github pull requests via bash script, specifically raising pull requests for forked branches. I've successfully done it for private repos, however it doesn't seem to work for public repos (see code below):
curl -H "Authorization: bearer <accesstoken>" -d '{"title":"SOMETITLE","base":"master","head":"'"someuser"':'"someForkedBranch"'","body":"some words to fill body."}' https://api.github.com/repos/<user-name>/<repo-name>/pulls
Any help would be appreciated.
If this is for creating a PR, you would need a -X POST somewhere in your curl command, in order to POST the query for a new PR:
curl \
-X POST \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/octocat/hello-world/pulls \
-d '{"head":"head","base":"base"}'
Make sure also to use the right oauth/PAT or SAML SSO:
curl -v -H "Authorization: token TOKEN" -X POST ...
Those token have just seen a new format update (Apr. 2021) so you might need to regenerate one.

Sending email using cURL with a password with special character in bash script

I have an SMTP configuration like the follows: (everything is dummy data)
SMTP_USERNAME="fakenews#yahoo.comg"
SMTP_SERVER="smtp.office365.com"
SMTP_PASSWORD='rdjsllskdslsds!'
SMTP_PORT="587"
EMAIL_FROM="support#fakernews.com"
EMAIL_TO="rfakeuser#fakernews.com"
Note the "!" mark at the end of the password. This cannot be changed.
When I run the below command with everything hardcoded, it works fine, and an email is sent.
curl --url smtp://smtp.office365.com:587 --mail-from support#fakernews.com --mail-rcpt rfakeuser#fakernews.com --upload-file tempemailbody_1.txt --user fakenews#yahoo.comg:rdjsllskdslsds! --ssl
However, when I replace them with variables, as below, I keep getting access denied.
curl --url "smtp://$SMTP_SERVER:$SMTP_PORT" --mail-from $EMAIL_FROM --mail-rcpt $EMAIL_TO --upload-file tempemailbody_1.txt --user "$SMTP_USERNAME:$SMTP_PASSWORD" --ssl
The error message is :
curl: (9) remote access denied: 501
I think that this is because somehow the variable interpretation is causing the issue, but I cant figure out what is it. What should I change in the command to make it work ?

Jira API GET all users from Jira project with specific status

In my Ruby app I'm trying to get all agent users from my service desk board. It means all users with status: 'ServiceDesk'. Is it possible using only base auth?
In curl I was trying something like:
curl -D -u USERNAME:PASSWORD -X GET -H "Content-Type: application/json" https://company_name.atlassian.net/rest/api/2/user/assignable/search?project=SERVICEDESK
But all what I get is an error:
Warning: The file name argument '-u' looks like a flag.
curl: (3) URL using bad/illegal format or missing URL
{"errorMessages":["Internal server error"],"errors":{}}%
Is there any way to get those data with basic auth?
I think there's an issue with the curl command, try this
curl -D- -u USERNAME:PASSWORD https://company_name.atlassian.net/rest/api/2/user/assignable/search?project=SERVICEDESK

Curl command on windows not passing user:pass correctly

I'm using CURL to execute some API calls against a bitbucket server. The command is like this:
curl https://bitbucket.myserver.com/rest/api/1.0/projects/PRJ/repos/repo-slug/tags \
-u 'user:pass' \
-X POST \
-H 'Content-type: application/json' \
-d '{"name" : "test-tag", "message": "Test tag from curl", "startPoint": "master" }'
This is expected to create a tag on the master branch in the repo. This however fails complaining of incorrect username/password.
I then copy/paste the command into git-bash prompt - and it works as expected, completing successfully. I tried this with multiple user accounts. I also tried specifying only the username and then entering the password on command line - with the same results.
How can I get curl on windows to pass correct username/password to the server?

Why I can't use API for common user integrated with OIDC in ICP(IBM cloud private)

https://www.ibm.com/support/knowledgecenter/SSBS6K_2.1.0/apis/auth_manage_api.html
I try to use the API for common user integrated with OIDC, but the error msg shows:
{"error_description":"invalid_resource_owner_credential","error":"server_error"}
command as the following
curl -k -H "Content-Type: application/x-www-form-urlencoded;charset=UTF-8" -d "grant_type=password&username=abc\#test\.com&password=ChangeMe\!\#\#&scope=openid" https://<cluster_access_ip>:8443/idprovider/v1/auth/identitytoken --insecure
But it is working fine for the administrator: admin/admin, so strange.
Issue is with the special character "!" which is used for history expansions in command line prompt.
You can use below command which works...
curl -k -H "Content-Type: application/x-www-form-urlencoded;charset=UTF-8" -d "grant_type=password&username=abc#test.com&password=ChangeMe"'!'"##&scope=openid" https://<cluster_access_ip>:8443/idprovider/v1/auth/identitytoken --insecure
Have you configured the LDAP, created Teams and added users to the team? Did you check the logs on Master node /var/log/containers for platform-identity-manager, _platform-auth-service, *platform-identity-provider?

Resources