I connect to multiple Asterisk PBXs from my Mac, and it’s getting a real drag to have to open terminal, ssh to the PBX and the su to root just to issue “asterisk -rT”. Here’s a method that allows you to select the PBX from the terminal Library and it does all the work for you.

First of you need to setup your SSH environment. On your Mac, if you haven’t already you need to generate your SSH key. Start up terminal and type: “ssh-keygen”. When it asks for a password just hit enter. This should have generated two files in your “.ssh” directory “id_rsa.pub” and “id_rsa”. The “id_rsa.pub” is your public key which you’ll be copying to the asterisk server.

SSH over to the asterisk PBX and cd into your “.ssh/” directory. Create a file called “authorized_keys” and copy the entry from your “id_rsa.pub” file. NOTE, this entry should be all on one line. Save the file and make sure the permissions are set right “chmod 644 authorized_keys”.

Now you should be able to ssh over to your PBX without requiring a password.. Cool huh!

Now it’s really annoying and dangerous to have to SU to root just to run the asterisk console, so lets change that. “sudo chmod 4755 /usr/sbin/asterisk”. Now you can run “/usr/sbin/asterisk -rT” without being root.

And bring it all together, Right click on terminal in the Dock, select “new Command”, and enter “ssh -t /usr/sbin/asterisk -rT”, hit “run”, and wow your connected straight to the asterisk console!. “file->save” the window and now you can select the window from the library.

Oh what if the username on your Mac is not the same username on the PBX? Well that’s simple to.. on your mac create a “.ssh/config” file with the following entries:

host Pbx-host hostname PBX-Host user your-username-on-PBX

all done! Enjoy