I need to create a UNIX user account where if a user uses that account to login through SSH into the asterisk box he will get the Asterisk CLI and if he exits the CLI he will be logged out and SSH connection will be closed
Any ideas on how to achieve that ?
Providing that your Unix supports executable scripts for exec (2), put this in a file:
exec /usr/sbin/asterisk -r
mark it readable and executable, and make in the login shell.
I’ve not tried this, so you may need to make it set environment variables, e.g.SHELL. Note that asterisk -r can shell out.