Archive for the ‘ Ubiquiti ’ Category

Boot Script (Startup Script) with Ubiquiti AirOS

I have been hitting my head against the wall trying to set the bridge priority of a few radios involved in spanning tree. It is easy to log in to the radio and change the priority with the brctl setbridgeprio br0 . But what if you want to change it on boot and automatically? I dug through the Ubiquiti forums only to find bits and pieces that lead me to the final solution.

There are a number of key files that don’t exist by default, but can be setup to provide the scripting functionality you may need.


/etc/persistent/rc.presysinit
/etc/persistent/rc.postsysinit

/etc/persistent/rc.prestart
/etc/persistent/rc.poststart

/etc/persistent/rc.prestop
/etc/persistent/rc.poststop

If you have read any of my other posts you will see that I am a huge supporter of VIM, and will assume you are using it. You can simply do vi /etc/persistent/ and then write your script. For my example, I will give you a copy of my bridge priority script:


#!/bin/sh
brctl setbridgeprio br0 7000
brctl setpathcost ath0 10

In a previous post I talked about the command that makes your /etc/ directory and changes to it persistent.


cfgmtd -w -p /etc/

This command will write the changes to /etc/ to flash and then you will be able to reboot the system and the new script will take effect. Hopefully you found this helpful.

Cheers,

-Mike

Remote Keybased Login with SSH to AirOS

I found the holy grail for any network admin, password-less login. This gives you the power to run remote scripts, forget passwords, and control the world… well maybe. Anyways, lets get to it. This specific post is talking about how to remotely login to an AirOS system (Ubiquiti). I’ll assume you are using a Linux system, or if not, you will need to know how to generate your own rsa key.

First, open an ssh session to the radio in question and do the following:

#vi /tmp/system.cfg

Next add users.1.homedir=/etc/persistent and type the following:


#cfgmtd -w -p /etc/
#reboot

Next do ssh-keygen to generate a new RSA key. You will be asked for a directory and a passphrase. Make sure you leave passphrase blank, or you will have to enter that key each time.

Now you will need to make a directory and copy the public key to the AirOS system:

#ssh username@x.x.x.x 'mkdir /etc/persistent/.ssh/'
#cat ~/.ssh/id_rsa.pub | ssh username@x.x.x.x 'cat >> /etc/persistent/.ssh/authorized_keys'

If you changed the directory during the ssh-keygen process, make the change in the command above.

Now make your changes persistent with this command:
#cfgmtd -w -p /etc/

You should be able to login without a password!

Cheers,

Mike