Logging in using curl

  • Access to the switch REST API must be enabled.


Credential information (user name, password, domain, and authentication tokens) used in curl commands entered at a command-line prompt might be saved in the command history. For security reasons, Hewlett Packard Enterprise recommends that you disable command history before executing commands containing credential information.

Use the following curl command to access the login resource of the switch and provide your user name and password as data:


curl -k[ --noproxy <IP-ADDR>] POST 
-H 'Content-Type: application/x-www-form-urlencoded'
--data 'username=<USER-NAME>&password=<PASSWORD>'

Specifies that the curl program not attempt to verify the server certificate against the list of certificate authorities included with the curl software.

The switch uses self-signed certificates. By default, the curl program attempts to verify certificates against its list of certificate authorities, and attempts to verify self-signed certificates fail. Therefore you must use the –k option to disable attempts to verify self-signed certificates against a certificate authority.

--noproxy <IP-ADDR>

Optional. The --noproxy option is appropriate where execution of curl commands does not need a proxy to access the applications. If your network is configured to require a proxy to access applications, use the --proxy option. <IP-ADDR> specifies the IP address or hostname of the switch.


Specifies the file in which to store the session cookie. This session cookie is required when you execute subsequent curl commands.


Specifies the user name.


Specifies the password for the user.


Although it is possible to pass the user name and password information as a query string in the login URI, system logs save the accessed URI in cleartext in log entries. Hewlett Packard Enterprise recommends that you pass the credential information as data instead of in the URI when using programs such as curl to log in to the switch.


$ curl --noproxy -k POST \
-c /tmp/auth_cookie \
-H 'Content-Type: application/x-www-form-urlencoded' \
"" \
--data 'username=admin&password=admin'