Asterisk Manager - Authentication failed

Hi guys,

I’ve been spending all the day trying to connect to the Asterisk Manger but I still get this message :

ASTERISK MANAGER OUTPUT:
Asterisk Call Manager/1.1
Response: Error
Message: Authentication failed

I’m getting crazy… so here is my config :

manager.conf

[general]
enabled = yes
port = 5038
bindaddr = 127.0.0.1

[test]
secret = test
read = system,call,log,verbose,command,agent,user
write = system,call,log,verbose,command,agent,user
deny=0.0.0.0/0.0.0.0
permit=127.0.0.1/255.255.255.255

http.conf

[general]
enabled=yes
enablestatic=yes
bindaddr=0.0.0.0

What I’m doing :

$errno = “”;
$errstr = “”;
$timeout = “30”;

$socket = fsockopen(“127.0.0.1”,“5038”, $errno, $errstr, $timeout);
fputs($socket, “Action: Login\r\n”);
fputs($socket, “UserName: test\r\n”);
fputs($socket, “Secret: test\r\n\r\n”);
fputs($socket, “\r\n”);
fputs($socket, “\r\n\r\n”);
fputs($socket, “Action: ListCommands\r\n\r\n”);
fputs($socket, “Action: Logoff\r\n\r\n”);
while (!feof($socket)) {
$wrets .= fread($socket, 4096);
}
fclose($socket);
echo “ASTERISK MANAGER OUTPUT:$wrets”;

My server is located on a public adress : 91.121.72.X

It’s very important, Could you please help me ?

Thank you 1000 times !

Vincent.

Howdy,

Here’s my manager.conf:

[general]
displaysystemname=yes
enabled=yes
webenabled=no
port=5038
bindaddr = 127.0.0.1
[admin]
secret = admin
deny=0.0.0.0/0.0.0.0
permit=127.0.0.1/255.255.255.255
read = system,call,log,verbose,command,agent,user,config
write=system,call,log,verbose,command,agent,user,config

And I use the same test php code that you did:

<?php

$errno = "";
$errstr = "";
$timeout = "30";

$socket = fsockopen("127.0.0.1","5038", $errno, $errstr, $timeout);
fputs($socket, "Action: Login\r\n");
fputs($socket, "UserName: admin\r\n");
fputs($socket, "Secret: admin\r\n\r\n");
fputs($socket, "Action: ListCommands\r\n\r\n");
fputs($socket, "Action: Logoff\r\n\r\n");
while (!feof($socket)) {
$wrets .= fread($socket, 4096);
}
fclose($socket);
echo "ASTERISK MANAGER OUTPUT:$wrets";
?>

And my output, from running the script locally, e.g. “php test.php” is:

root@host:/etc/asterisk/scripts# php text.php 
ASTERISK MANAGER OUTPUT:Asterisk Call Manager/1.1
Response: Success
Message: Authentication accepted

Event: FullyBooted
Privilege: system,all
Status: Fully Booted

Response: Success
WaitEvent: Wait for an event to occur.  (Priv: <none>)
...
<snip>
...
DataGet: Retrieve the data api tree.  (Priv: <none>)

Response: Goodbye
Message: Thanks for all the fish.

I’m using 1.8 out of SVN.

Hi,

The problem persist, is my html.conf correct ?

The script is located in my folder /var/www/

Is there anyway to see why it doesn’t work ?

Thank you very much for you help,

Vincent.

That php code is from a web page?

Are you running that http server on the same server as Asterisk is running?

yes… it is from a web page on the same server that asterisk is running

I did it exactly the same way, I created test.php into etc/asterisk/script/
I ran it and the output is still the same :frowning:

may sound stupid, but i always forget to do it: after you added [test] in your manager.conf, did you restarted asterisk?

in my log I can see that :

[Dec 16 19:17:39] WARNING[23113] cel_manager.c: Failed to load configuration file. CEL manager Module not activated.

Is it important ?

and the command manager show user admin :

ns351866*CLI> manager show user admin

   username: admin
     secret: <Set>
        acl: yes
  read perm: system,call,log,verbose,command,agent,user,config,all
 write perm: system,call,log,verbose,command,agent,user,config,all

displayconnects: yes

it looks ok…but it doesn’t work

yes i restarted Asterisk :smile:

you should probably be more concerned about what “manager show user test” says.

take it step by step. open telnet to port 5038 from your machine. type “Action: LoginUserName: test” and so on. see what you get. what’s the output from your php script?

I just did it and got :

Reponse: Error
Message: Permission denied

I’m getting crazy, I don’t know what to do :frowning:
I don’t have a clue I triedeverything

*CLI> manager show users

username

admin
test

2 manager users configured.
*CLI> manager show user test

   username: test
     secret: <Set>
        acl: yes
  read perm: system,call,log,verbose,command,agent,user,config,all
 write perm: system,call,log,verbose,command,agent,user,config,all

displayconnects: yes

They are both configured… it should work no ?

<?php $errno = ""; $errstr = ""; $timeout = "30"; $socket = fsockopen("127.0.0.1","5038", $errno, $errstr, $timeout); fputs($socket, "Action: Login\r\n"); fputs($socket, "UserName: test\r\n"); fputs($socket, "Secret: test\r\n\r\n"); fputs($socket, "Action: ListCommands\r\n\r\n"); fputs($socket, "Action: Logoff\r\n\r\n"); while (!feof($socket)) { $wrets .= fread($socket, 4096); } fclose($socket); echo "ASTERISK MANAGER OUTPUT:$wrets"; ?>

Is my http.conf wrong ?

[general]
enabled=yes
enablestatic=yes
bindaddr=0.0.0.0

http.conf is out of question for now, as the trouble is that your “test” user is simply not granted access to the AMI. i dont know if theres something else that could prevent manager logins… maybe some setting in asterisk.conf? i doubt it. also, try enabling debug in manager.conf (add a “debug=yes” line under [general]), maybe that will give you some more clues

Why are you trying to enable Asterisk’s http server? Your PHP script is running on some other server, connecting to Asterisk’s manager interface. Where is the Asterisk http interface a part of this?

By default manager.conf does not enable the http server, that’s done by setting webenabled=yes.

Cheers.

Hi guys,

I tried to connect through telnet, I get the same error message :

Response: Error Message: Authentication failed

Is there a way to get the manager logins debug ?

I clearly have configured

[test]
secret=test
deny=0.0.0.0/0.0.0.0
permit=127.0.0.1/255.255.255.255
read = system,call,log,verbose,command,agent,user,config
write=system,call,log,verbose,command,agent,user,config

*CLI> manager show user test
username: test
secret:
acl: yes
read perm: system,call,log,verbose,command,agent,user,config,all
write perm: system,call,log,verbose,command,agent,user,config,all
displayconnects: yes

It’s awful, there’s no way to authenticate :frowning:
Is there any trustful person who would like to have a look at it directly ?

thank you very much !

try something very simple. I’ve got the same problem and then realized that my server ip was not informed on manager.conf

[admin]
secret = 123
deny=0.0.0.0/0.0.0.0
permit=127.0.0.1/255.255.255.0
permit=YOUR_SERVER_IP/255.255.255.0
read = system,call,log,verbose,command,agent,user,config,command,dtmf,reporting,cdr,dialplan,originate
write = system,call,log,verbose,command,agent,user,config,command,dtmf,reporting,cdr,dialplan,originate