Installing sshpass on OS X

Note: To install sshpass you need to make sure you have Xcode installed along with the Xcode command line tools.  You can download Xcode from the app store, and then install the command line tools from Xcode’s Preferences.

Now open up your terminal and run the following commands.

Download sshpass from source forge.

curl -O -L http://downloads.sourceforge.net/project/sshpass/sshpass/1.05/sshpass-1.05.tar.gz

Extract the tarball and cd into the directory.

tar zxvf sshpass-1.05.tar.gz && cd sshpass-1.05

make and install.

./configure
make
sudo make install

Now test and make sure it works

sshpass -V

You should receive the following.

sshpass 1.05 (C) 2006-2011 Lingnu Open Source Consulting Ltd.
This program is free software, and can be distributed under the terms of the GPL
See the COPYING file for more information.

 

Download file from the web using curl

The following command basically does the same thing as wget.  This can come in handy since OS X and some linux distros do not ship with wget by default.

curl -O -L www.incredigeek.com/home/downloads/wget/wget-1.14.tar.gz

The two options do the following

-O, –remote-name Write output to a file named as the remote file
-L, –location Follow redirects (H)

Ubiquiti AirMax SSH Commands

ssh ubnt@192.168.1.20

AP:

list how many devices are connected.

wstalist |grep \"mac\" |wc -l
or
wstalist |grep -c \"mac\" 

List connected devices

wstalist

List ip’s of connected devices

wstalist |grep \"lastip\" | awk '{print $3}' | sed s/\"/\ /g | sed s/,//g

List connected devices with the device name and ip address of device

wstalist |grep -A1 \"name\" | sed s/\"/\ /g | sed s/,//g | grep -v "\--"

List connected devices along with device name, and signal.

wstalist |grep -A6 \"name\" | grep -E -v 'rx|tx|associd|aprepeater' | sed s/\"/\ /g | sed s/,//g | grep -v "\--"

 

Station:

Signal:

mca-status | grep signal

Signal, essid, frequency, noise, and ccq:

mca-status | grep -A4 essid

List basic info like device name, mac address, firmware version, platform, etc.

mca-status | head -n 1

Show Firmware Version:

mca-status | head -n 1 | awk -F, '{print $3}'

 

 

 

 

 

Create an Image of Hard Drive with ddrescue on OS X

Install ddrescue

sudo port install ddrescue

If you don’t have ports installed, then I would recommend doing some web searching on how to install ddrescue.

Identify Disk:

identify the “name” of the disk you want to “image” .

diskutil list

Example:

Macbook:~ bob$ diskutil list
 /dev/disk0
 #:                       TYPE NAME                    SIZE       IDENTIFIER
 0:      GUID_partition_scheme                        *200.1 GB   disk0
 1:                        EFI EFI                     204.2 MB   disk0s1
 2:                  Apple_HFS Mac                     199.7 GB   disk0s2
 3:                 Apple_Boot Recovery HD             641.1 MB   disk0s3
 /dev/disk1
 #:                       TYPE NAME                    SIZE       IDENTIFIER
 0:     FDisk_partition_scheme                        *250.8 GB   disk1
 1:               Windows_NTFS Windows Hard Drive      250.8 GB   disk1s1
 Macbook:~ bob$

The first disk “disk0” is the OS X System disk, the second one “disk1” is an external drive, the one I want to image.

Recovery/Image command:

Change /dev/disk1s1 to your disk.  If you have multiple partitions and want to image the whole drive then just use the disk name like “/dev/disk1”  instead of  “/dev/disk1s1”.

sudo ddrescue -v /dev/disk1s1 ~/Desktop/ddrescue.dmg ddrescue.log

In the above command I am attempting to rescue data from the first partition on disk1 and send it to an image “ddrescue.dmg” on my desktop.

Now go get some coffee, lunch, etc. and it might be finished when you get back…

 

 

 

 

 

 

How to Create a Bootable OS X Yosemite USB Drive from OS X

Requirements

  1. 8GB+ USB drive with nothing important on it
  2. Computer running OS X

1. In Disk Utility format your USB drive as HFS+

2. Open up a terminal and mount the Yosemite Installer

sudo hdiutil attach /Applications/Install\ OS\ X\ Yosemite.app/Contents/SharedSupport/InstallESD.dmg

3. Restore the Yosemite InstallESD.dmg to your USB drive.  Replace “USBDrive” with the name of your drive.  You will be prompted for a Yes or No.  Hit y and then Enter to continue and erase all the data on the USB drive.

sudo asr restore -source /Volumes/OS\ X\ Install\ ESD/BaseSystem.dmg -target /Volumes/USBDrive -erase -format HFS+

4. Delete and add some packages.

sudo rm /Volumes/OS\ X\ Base\ System/System/Installation/Packages
sudo cp -a /Volumes/OS\ X\ Install\ ESD/Packages /Volumes/OS\ X\ Base\ System/System/Installation/Packages

5. Copy some more files.

sudo cp -a /Volumes/OS\ X\ Install\ ESD/BaseSystem.chunklist /Volumes/OS\ X\ Base/System/
sudo cp -a /Volumes/OS\ X\ Install\ ESD/BaseSystem.dmg /Volumes/OS\ X\ Base/System/

7. Detach the USB Drive

hdiutil detach /Volumes/OS\ X\ Install\ ESD/

8. Plug the drive into a mac and start the installation.

Control LED from Command Line – Raspberry Pi

Replace “4” with the GPIO pin your using.

echo "4" > /sys/class/gpio/export

Setup the direction.  If it was a button or switch we would change “out” to “in”.

echo "out" > /sys/class/gpio/gpio4/direction

Turn the LED on.

echo "1" > /sys/class/gpio/gpio4/value

Turn the LED off.

echo "0" > /sys/class/gpio/gpio4/value

1 = on and 0 = off.

 

How to Install Nagios 4.0.8 on CentOS 6.5

Install the prerequisite packages

yum install gd gd-devel httpd php gcc glibc glibc-common make perl wget

If you want to monitor SNMP you should install net-snmp now

yum install net-snmp net-snmp-utils
service snmpd start
chkconfig snmpd on

Create the Nagios user.

useradd -m nagios
passwd nagios
groupadd nagcmd
usermod -a -G nagcmd nagios
usermod -a -G nagcmd apache

Create a directory to download and build Nagios from

mkdir /root/nagios
cd /root/nagios

Download Nagios and the Nagios plugins

wget http://sourceforge.net/projects/nagios/files/nagios-4.x/nagios-4.0.8/nagios-4.0.8.tar.gz
wget nagios-plugins.org/download/nagios-plugins-2.0.3.tar.gz 

Extract the Nagios zip

tar xvzf nagios-4.0.8.tar.gz
cd nagios-4.0.8

Compile and make it

./configure
make all
make install
make install-init
make install-commandmode
make install-config
make install-webconf

Create a password so you can login to the web interface

htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin

Enable Nagios on startup

 chkconfig nagios on

Start the service

service nagios start

Install the plugins.

cd ..
tar xvzf nagios-plugins-2.0.2.tar.gz
cd nagios-plugins-2.0.2
./configure
make
make install

Start apache and make sure it starts on boot.

service httpd start
chkconfig httpd on

You should now be able to access Nagios by going to https://nagiosserverip/nagios

If you run into issues check your firewall and make sure SELinux is disabled.

How To Enable/Disable SELinux

Disable SELinux

You can manually edit the SELinux config file in /etc/selinux/config and change the variable SELINUX=enforcing to disabled

vi /etc/selinux/config
...
SELINUX=disabled
...

or you can use this little command

sed -i.bak -e 's/^SELINUX=.*/SELINUX=disabled/g' /etc/selinux/config

Enable SELinux

You can enable SELinux manually the same as above but set SELINUX=disabled to SELINUX=enforcing

vi /etc/selinux/config
...
SELINUX=enforcing
...

or

sed -i.bak -e 's/^SELINUX=.*/SELINUX=enforcing/g' /etc/selinux/config

How to Allow a Port Through Firewalld

Note: If you have SELinux enabled you’ll need to allow the port in semanage.

Basic syntax

 firewall-cmd --zone=public --add-port=(port number)/(protocal)

So the command to allow port 80 through the firewall would be

firewall-cmd --zone=public --add-port=http/tcp
or
firewall-cmd --zone=public --add-port=80/tcp

The above command only works for the running instance of firewalld.  If you want to add the port permanetely you need to run the above command and then run it again with “–permanent” added to the end of the command.

example:

firewall-cmd --zone=public --add-port=http/tcp
firewall-cmd --zone=public --add-port=http/tcp --permanent

How To Install Zenoss 4.2.5 on CentOS 6.5

First you need to remove mysql-libs

yum remove mysql-libs

Install wget

yum install -y wget

Download the Zenoss install script archive

wget https://github.com/zenoss/core-autodeploy/tarball/4.2.5 -O auto.tar.gz

Extract the archive

tar zxvf auto.tar.gz

and execute the install script

cd zenoss-core-autodeploy-*
./core-autodeploy.sh

Follow the prompts and when it’s finished navigate to http://yourserverip:8080 to complete the install.