{"id":1590,"date":"2017-05-04T04:49:43","date_gmt":"2017-05-04T04:49:43","guid":{"rendered":"http:\/\/www.incredigeek.com\/home\/?page_id=1590"},"modified":"2022-09-16T16:59:51","modified_gmt":"2022-09-16T21:59:51","slug":"ubntmod","status":"publish","type":"page","link":"https:\/\/www.incredigeek.com\/home\/ubntmod\/","title":{"rendered":"UBNTMOD"},"content":{"rendered":"\n<p>UBNTMOD is a tool(Shell Script) that allows you to configure a vast amount of settings on Ubiquiti AirMax equipment from the Linux command line.&nbsp; The script can be used for helping automate task like reboots and firmware updates, and\/or be used to change settings like device name, ssid, enable or disable NTP, and Syslog.&nbsp; For a complete list of functions look at the UBNTMOD HELP section.<\/p>\n\n\n\n<p>The script has been tested and any known bugs should be listed at the bottom of this page, but use at your own risk.&nbsp; This is a bash script so feel free to download, review, copy, add, tweak, and remove all or parts of the code.<\/p>\n\n\n\n<p><strong>Install Prerequisites<\/strong><\/p>\n\n\n\n<p>The only requirements outside of a Bash shell is having sshpass installed.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo apt install sshpass<\/pre>\n\n\n\n<h1 class=\"wp-block-heading\">Download script<\/h1>\n\n\n\n<p>Download the script <a href=\"http:\/\/incredigeek.com\/home\/downloads\/ubntmod\/ubntmod.sh\">here<\/a> or with wget<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">wget http:\/\/incredigeek.com\/home\/downloads\/ubntmod\/ubntmod.sh<\/pre>\n\n\n\n<p>Make executable<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">chmod +x .\/ubntmod.sh<\/pre>\n\n\n\n<p>Run script<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">.\/ubntmod.sh -h<\/pre>\n\n\n\n<h1 class=\"wp-block-heading\">&nbsp;<\/h1>\n\n\n\n<h1 class=\"wp-block-heading\">Running script and basic usage<\/h1>\n\n\n\n<p>Basic syntax is<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">.\/ubntmod.sh -i {device ip} -o otheroptions<\/pre>\n\n\n\n<p>Example : Print firmware version<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">user:~$ .\/ubntmod.sh -i 192.168.1.20 -U info\ninfo\nPrinting firmware version\nfirmwareVersion=XM.ar7240.v6.0.3.30600.170329.1831\nuser:~$<\/pre>\n\n\n\n<p>A note about saving changes<\/p>\n\n\n\n<p>If you make a change to a device like change the name, you&#8217;ll need to save and apply the changes to the radio.&nbsp; Do this by using the -Z option, it writes the changes and reboots the device so the changes take effect.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">.\/ubntmod.sh -i 192.168.1.20 -N \"New Device\" -Z<\/pre>\n\n\n\n<p>Tip : You can string a bunch of options together and then save them all at once,<\/p>\n\n\n\n<p>Example : Change device name, username, and enable NTP.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">.\/ubntmod.sh -i 192.168.1.20 -N \"New Device\" -u admin -n enable -Z<\/pre>\n\n\n\n<p>A note about usernames and passwords<\/p>\n\n\n\n<p>In the script there are two variables &#8220;un&#8221; and &#8220;pw&#8221; which specify the username and password to use when connecting to the radios.&nbsp; By default these are ubnt and ubnt.&nbsp; you can change these in the script so the script uses some other default username and password, or you can specify the username and password with the &#8220;-y&#8221; option.<\/p>\n\n\n\n<p>So in our first example, if the username and password are different then ubnt we use the -y option<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">.\/ubntmod.sh -i 192.168.1.20 -U info -y 'admin,password123'<\/pre>\n\n\n\n<p>All other needed information should be in the help part of the script, accessible with the -h argument.<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">&nbsp;<\/h1>\n\n\n\n<h1 class=\"wp-block-heading\">UBNTMOD HELP<\/h1>\n\n\n\n<pre class=\"wp-block-preformatted\">.\/ubntmod.sh -h<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\\\\\n\\\\ UBNTMOD tool 1.0.8  \\\\\n \\\\\/___\/___\/___\/___\/___\/\/\n\nHelp and Usage\n\nUsage: .\/ubntmod.sh -i TargetIP {OPTIONS}\nExample: Add SSH Key to 192.168.1.20\n.\/ubntmod.sh -i 192.168.1.20 -K id_rsa.pub -Z\n\nDevice to operate against\n-i IPADDRESS,                           IP Address of the device.\n\nOption usage\n-a remove,                              Removes AirControl provisioning.  Works on AC1 and AC2\n-D enable\/disable,                      Enable or Disable DNS proxy\n-e  ,                                   See if radio resolves DNS.  SSH's to the radio and pings a domain name to see if it can resolve\n-N Device Name,                         Change name of the device.\n-n enable\/disable,                      Enable or Disable NTP server\n-K SSH Key,                             Specifies to path to the Public SSH Key file i.e. id_rsa.pub\n-l enable\/disable,                      Enable or Disable Syslog.  Specify ip address if you want to enable remote syslog\necho \"-p 'password',                            Change password for device.  You can use the -z option to save.\"\n-P PSK key,                             Change wireless passkey\n-r KEYTODEL,                            Replace KEYTODEL with key1(to delete the first SSH Key), key2(to delete the second Key), or allkeys(to delete all current SSH Keys on the device)\n-S SSID,                                Change SSID.  Spaces are not supported in SSID field yet.\n-s \"community;contact;location\"         Enable and set SNMP\n-t enable\/disable,                      Enable or Disable Traffic Shaping on device, note: you cannot set the speed limits from this program.\n-c fromText,                            The c and C Options are for making custom changes to the \/tmp\/system.cfg file, put the text you want to change after the -c option\n-C toText,                              The C and c Options are for making custom changes to the \/tmp\/system.cfg file, put the text you want the -c text to be changed to after the -C option.  See below example\n-w Channel Width,                       Set Channel Width i.e.(-w 10) for 10mhz\n-u username,                            Change default username for the device\n-U firmware,                            Upgrade device firmware, can print current firmware version the option argument is version, info, or status\n\nDevice Operations\n-B,                                    Backs up configuration of device.  Script automatically names and time stamps the backup\n-b BACUPNAME,                           Restores a backup configuration from the specified file\n-I,                                     Prints info about device\n-d,                                     Run Discovery on device\n-R,                                    Reboot Device.\n-A,                                    Reboot devices connected to AP, then reboot the AP.  Needs jq installed.  You can reboot multiple AP's by putting the IP's in an ap.lst file (one ip per line).\n-w Channel Width,                       Changes channel width to whatever is specified, just the number no need to add mhz to the end, supported channel widths are 5,8,10,20,40 mhz\n-W,                                     WIFI Scan, runs a scan, same thing as site survey\n-X COMMAND,                             Run a custom Command on device, like \"ls\", \"grep ssid \/tmp\/system.cfg\"  Make sure to put the command in \"\"\n-y \\'username,password\\',               Specify username and password to use in script\n-Y,                                     Update ubntmod script with the latest available\n-z,                                       Saves changes without a reboot by executing \/usr\/etc\/rc.d\/rc.softrestart save\n-Z,                                     Saves changes made and reboots device to apply changes\n\n\n\nc and C Example\n\nbasic usage:\n.\/ubntmod.sh -i IPADDRESS -c linetochange -C changetoline\n.\/ubntmod.sh -i 192.168.1.20 -c snmp.status=enabled -C snmp.status=disable\nThe above line changes the \"snmp.status=enabled\" to \"snmp.status=disabled\"\n\nFind more help and tutorials at http:\/\/incredigeek.com\/home\/UBNTMOD<\/pre>\n\n\n\n<h1 class=\"wp-block-heading\">&nbsp;<\/h1>\n\n\n\n<h1 class=\"wp-block-heading\">&nbsp;<\/h1>\n\n\n\n<h1 class=\"wp-block-heading\">Examples<\/h1>\n\n\n\n<p>Reboot<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">.\/ubntmod.sh -i 192.168.1.20 -R<\/pre>\n\n\n\n<p>Wireless Scan<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">.\/ubntmod.sh -i 192.168.1.20 -W<\/pre>\n\n\n\n<p>Discovery<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">user:~$ .\/ubntmod.sh -i 192.168.1.20 -d\nHardware Address  IP            address Name\n00:27:A8:BB:2A:CD 192.168.1.20  NanoStation M2 'UBNT'\n00:27:A8:AB:32:4A 192.168.1.1   NanoStation M2 'AP'\nTotal: 2 devices.\nuser:~$<\/pre>\n\n\n\n<p>Upgrade<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">user:~$ .\/ubntmod.sh -i 192.168.1.20 -U XM.v6.0.1.23382.160317.1806.bin<\/pre>\n\n\n\n<p>Backup Configuration<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">user:~$ .\/ubntmod.sh -i 192.168.1.20 -B AccessPoint\nbacking up configuration file for 192.168.1.1 Saving to AccessPoint.cfg\nuser:~$<\/pre>\n\n\n\n<p>Restore Configuration<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">.\/ubntmod.sh -i 192.168.1.20 -b AccessPoint.cfg<\/pre>\n\n\n\n<p>Change SNMP settings<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">.\/ubntmod.sh -i 192.168.1.20 -s \"public,netwatch@incredigeek.com,office\" -z<\/pre>\n\n\n\n<p>Change Device name<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">.\/ubntmod.sh -i 192.168.1.20 -N \"device name\" -Z<\/pre>\n\n\n\n<p>Check if radio can resolve DNS<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">.\/ubntmod.sh -i 192.168.1.20 -e<\/pre>\n\n\n\n<p><strong>Softrestart <\/strong><\/p>\n\n\n\n<p><em>The following options have been tested and work with the softrestart option<\/em><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>SNMP<\/li><li>SSID<\/li><\/ul>\n\n\n\n<p>Want a specific example or new features?&nbsp; Leave a comment!<\/p>\n\n\n\n<p><strong>Future Changes<br><\/strong>UNMS support for adding, disabling etc<br>Send changes to Slack or Teams channel<br>Support for multiple usernames and passwords<strong><br><\/strong><del>Support for soft restart, or where device doesn&#8217;t have to reboot to apply a change<\/del> (implemented and testing)<br>support for testing a change before applying?<strong><br><\/strong><\/p>\n\n\n\n<p><strong>Latest Changes<\/strong><\/p>\n\n\n\n<p>### Version 1.0.8 (9\/3\/2022)<br>Added -A option to reboot devices connected to an access point. &nbsp;The jq utility needs to be installed. &nbsp;You can reboot multiple AP&#8217;s by putting the IP&#8217;s in an ap.lst file.<br>This release makes using ubntmod.sh much easier. It can now cycle through an infinite number of usernames\/passwords.<br>Refactored the username password section.<br>By default, ubntmod.sh will try reading from ubntmod.conf for usernames and passwords.<br>Added function to create ubntmod.conf file if username\/password is not specified and no config file exist.<\/p>\n\n\n\n<p>### Version 1.0.7<br>Added ssh-rsa in the HostKeyAlgorithms as recent versions of SSH do not support it by default<\/p>\n\n\n\n<p>### Version 1.0.6 (5\/24\/2019)<br>Enabled Remote syslog<\/p>\n\n\n\n<p>### Version 1.0.5 Changes (8\/9\/2019)<br>Added -z softrestart option to save changes without rebooting.&nbsp; May not work on all changes.<\/p>\n\n\n\n<p>### Version 1.0.4 Changes (5\/24\/2019)<br>Added Password loop option to specify two different passwords<br>Changed the SNMP deliminating character from , to ;<\/p>\n\n\n\n<p>### Version 1.0.3 Changes (9\/5\/2018)<br>Added support for testing if DNS resolves on device, -e option<\/p>\n\n\n\n<p>### Version 1.0.2 Changes (10\/31\/2018)<br>Added AirControl provisioning removal, -a option<\/p>\n\n\n\n<p>### Version 1.0.1 Changes (10\/31\/2018)<br># SNMP, changed help info to be correct<br># Backups, changed to automatically backup with device name and time stamp. There is a bug where if ubntmod.sh can&#8217;t access a radio to do a backup, it&#8217;ll create a empty file with the time stamp.<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>UBNTMOD is a tool(Shell Script) that allows you to configure a vast amount of settings on Ubiquiti AirMax equipment from the Linux command line.&nbsp; The script can be used for helping automate task like reboots and firmware updates, and\/or be &hellip; <a href=\"https:\/\/www.incredigeek.com\/home\/ubntmod\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-1590","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/pages\/1590","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/comments?post=1590"}],"version-history":[{"count":49,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/pages\/1590\/revisions"}],"predecessor-version":[{"id":4589,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/pages\/1590\/revisions\/4589"}],"wp:attachment":[{"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/media?parent=1590"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}