Curl

Commonly used for transferring data over multiple protocols like HTTPS, FTP, LDAP, etc., curl is particularly useful for debugging and troubleshooting connectivity and endpoint-related issues in environments and use-cases that lack proper tooling.

Options

OptionsValuesDescription
-X <REQUEST_TYPE>
--request
GET, POST, PUT, DELETESpecify the request type. Default GET
-vNAEnable verbose logging
-k
--insecure
NADisable Certificate checking (SSL/TLS disable)
-o <FILE_NAME>
--output
NASpecify output file to which response is written
-d 'RAW_DATA'
--data-raw
NARequest body for POST request
-CNAResume interrupted downloads
-LNAFollow redirects
-u <USER_NAME>:<PASSWORD>NABasic authentication
--header '<HEADER_VALUE>'
-H <HEADER_VALUE>
NAProvide header value REST request
-b <DATA>
--cookie "name1:value1; name2: value2"
NASpecify cookie headers
--basicNAExplicitly specify authentication type
--negotiateNASpecify kerberos authentication type
--http1.0NAForce to use http 1.0
--http1.1NAForce to use http 1.1
--http2NAForce to use http 2.0
--progress-barNAShows transfer progress bar

Packages and Install

Quick installation of the curl utility on different operating systems.

OSPackage Install CMD
Debian/Ubuntuapt install curl -y
CentOS/Fedora(DNF, MicroDNF, RPM)rpm install curl
OR
dnf install curl
Arch (Pacman)pacman -Sy curl
Alpine (APK-Docker)apk –no-cache add curl

Examples

  • Download a image file
curl -o logo.png https://reqbin.com/static/img/logo.png
  • Sending a custom header to the request
curl --header 'Host: targetapplication.com' https://192.0.0.1:8080/
  • Make a GET request with basic authentication.
curl -u user_name:password -X GET https//192.0.0.1:8000/someendpoint
  • Make a POST request with JWT authentication, skip HTTPS check, and provide JSON data.
curl -k -X POST https://localhost:8088/endpoint \
-H 'Accept: application/json' \
-H "Authorization: Bearer ${TOKEN}" \
--data '{"name": "John"}'
  • Make a REST request with Kerberos-enabled authentication, skip TLS, and enable verbose logging.
# Fetch the TGT token for kerberos principal
klist -kt /etc/krb5.keytab
kinit -kt /etc/krb5.keytab <PRINCIPAL>
klist

# Send the SPNEGO enabled request using the earlier fetched token
curl -kv --negotiate -u : <URL>
  • Download a file with progress.
curl --progress-bar -O https://localhost:8080/wp-content/temp.zip
  • Send a request using cookies.
curl -b "sessionid=123456" https://localhost:8080