Log in, Log out from Asterisk AMI with Telnet
Tips before the connecting
- Use commands rasterisk or asterisk -r to log in into the Asterisk console.
- On the asterisk console use the command show manager connected or manager show connected for Asterisk versions 1.4 or 1.8 respectively to list all the connections
- The file that it is used to configure the Asterisk AMI is the manager.conf (normly under /etc/). From this file we need mind some values in this file(bold text) for the telnet connection such us if it is enabled, port, context(admin in this case for UserName and secret for password)
displaysystemname = yes
enabled = yes
port = 5038
bindaddr = 127.0.0.1
secret = secret
writetimeout = 500
read = system,call,log,verbose,command,agent,user,config
write = system,call,log,verbose,command,agent,user,config
Step 1 - Telnet the AMI
Telnet the AMI, use the command telnet host port where the AMI is listening (normally port). Whe shoud see something like :
root@mymachine:/etc/asterisk# telnet localhost 5038
Connected to localhost.
Escape character is '^]'.
Asterisk Call Manager/1.0
Step 2 - Login the user
- Use the following commands to log in. The bold text must match with the information in the manager.conf. (You can copy&paste). Use always 2 empty lines to send the commands by pressing Intro twice.
Action: Login ActionID: 1 Username: admin Secret: secret
Message: Authentication accepted
* Now you can receive the events. Make a call o log in a user, or go to the Asterisk console to double check it.
Step 3 - Leave the Telnet
- Use the following command to leave the session. Press intro twice and you are out.