Using curl for Linode API commands

I'm trying to use curl to execute Linode API commands but I haven't been able to figure out how to have curl read my key from a file so that I don't have to enter the key in every command. This command works:

curl -u u:my-linode-key 'https://api.linode.com/?api_action=lino … deID=12345">https://api.linode.com/?api_action=linode.list&LinodeID=12345' | jsonpp

However this command doesn't work as I would expect (the key is in the linode_key.txt file):

curl -u u:@linodekey.txt 'https://api.linode.com/?api_action=lino … deID=12345">https://api.linode.com/?apiaction=linode.list&LinodeID=12345' | jsonpp

I've read the curl docs but I don't see what I'm doing wrong. Has anyone else managed to do this correctly? Thanks!

3 Replies

http://manpages.ubuntu.com/manpages/pre … url.1.html">http://manpages.ubuntu.com/manpages/precise/en/man1/curl.1.html

May want to search that for "password".

  • Les

You can supply the password via command substitution within the shell like this:

curl -u u:$(cat linode_key.txt) 'https://api.linode.com/?api_action=linode.list&LinodeID=12345' | jsonpp

Or you may find using the -n option and creating a .netrc file to be more convenient.

Thanks guys. Your answers were very helpful.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct