Posted on January 24, 2019 5:56 pm
 |  Asked by Jeroen Bosch
Print Friendly, PDF & Email

How can I pass my enable password when doing a API call?
When I disable my enable password everything works, but I would like to be able to execute API commands in both situations: thanks in advance!

Posted by Tamas Plugor
Answered on January 24, 2019 6:19 pm

Hi Jeroen,

What language are you trying to use?

For python we use the Server module from jsonrpclib

switch.runCmds(1,[ { “cmd”: “enable”, “input”: “password” }, “command“]

Other languages like perl and javascript are using jsonrpc as well and it’s well documented

For perl:

For javascript:

You can find these information on the web UI of eAPI on the switch as well, just connect to the switch from your browser and go to the Overview page


Hope this helps,

Forgot to add that we have a Perl example on this EOS central article:

you should be able to expand that and add the cmd + input keys in a similar fashion

(Tamas Plugor at January 24, 2019 7:09 pm)

I’ve just modified that script. This is the way to do it in perl:
My enable secret is “perl”

$err = &cmd($url,$data,[{“cmd” => “enable”,”input” => “perl”},”show version”]);
if (! $err) {
print $data->result->[1]{systemMacAddress},”n”;

This will throw the MAC address of the switch gotten from the output of show version


(Tamas Plugor at January 24, 2019 7:46 pm)

Thank you very much, great examples :)

(Jeroen Bosch at January 25, 2019 12:06 pm)

Post your Answer

You must be logged in to post an answer.