I recently upgraded and expanded the wireless network at the office. We replaced our outdated and failing Linksys WRT54G routers with a set of Ubiquiti Unifi UAP-AC-LITE access points. The process of upgrading the network has been one of the more enjoyable tasks I have been assigned recently and the new wireless system works amazingly well.
This guide outlines installing the Unifi Controller software on an Ubuntu 14.04 server for configuring and managing the access points as well as migration from one controller to another.
Recently I’ve been having issues with a VirtualBox machine crashing at random. The only common thread is a line of log file, and so far, google has not been helpful in determining the root cause. This machine is important enough that I need to know when it crashes, but not important enough to actually take the time to fix properly, so I researched and created a command to toss into cron to check the log file for the error line and email me when it finds it.
grep '<search text>' <file path> | ifne mailx -s "<email subject>" firstname.lastname@example.org -E
The command itself is simple. Search the log file with grep, if the search generated results send an email. I tried several iterations of this before finding one that did not email when the search was empty and also did not generate silent errors when empty as well. I run this via cron at 5 minute intervals
To use this command on ubuntu 14.04 you will need to install mailutils and moreutils
Software and versions used or mentioned:
Forum post with grep | mailx solution
ServerFault post with ifne solution
Traditionally ssh runs on port 22, but that does not mean it has to. Where I work each machine that runs ssh runs it on a different port. I do not know why, but it causes quite a bit of fun when trying to use common ssh based commands that all expect ssh to run on the default port. I have had to figure out more then a few of the workarounds and will share them because I had trouble finding a few of them.
SSH is easy to connect to a non-standard port, simply use the -p flag followed by the port number. Following is an example:
ssh -p 1000 email@example.com
For those who are not aware, you can create an identity file and copy it to the remote machine to allow you to log in without the need of a password (Link to the guide that taught me). ssh-copy-id assumes that the remote machine is running on port 22 and you have to trick it to change the port. We use the same -p flag as with ssh, but we need to put the whole of the arguments into single quotes for it to work. See the example below:
ssh-copy-id '-p 1000 -i ~/.ssh/id_rsa firstname.lastname@example.org'
rsync has a -e flag for setting which remote shell to use. after the -e flag you put the ssh options like is you were using ssh normally. Be sure to put them inside double quotes or they will get confused with rsync options. See the following example:
rsync -e "ssh -p 1000" /local/path/ email@example.com:/remote/path/
SCP is very easy, simply use the -P flag to set the port number, like in the following example:
scp -P 1000 /local/file firstname.lastname@example.org:/remote/file
Posted in Linux
Tagged cli, Linux, SSH
Recently I had the misfortune of having my windows virtual test machine fill up it’s hard drive. When I had created it, my host system had limited space and I only needed to test things in a windows environment inside a browser, so it got a small hard disk image. One day, while installing a new program, it simply ran out.
I could make a new virtual machine and re-install but that requires configuration, whereas resizing only takes time.
In command line, navigate to the directory with the troubled system’s hard disk image. Since I had exported and imported this machine when I moved from a desktop to my nice new (to me) laptop my disk image was in vmdk format, but you need a vdi format to resize. So first we convert the disk:
VBoxManage clonehd "source.vmdk" "copy.vdi" --format vdi
Once cloned, you can resize the vdi you just made. Please note that the size is in MB.
VBoxManage modifyhd "copy.vdi" --resize 30000
The disk is now resized, but not attached to our virtual machine. I simply edited the virtual machine to point to the resized copy. Alternatively you can convert the image back into vmdk and copy it over the original.
VBoxManage clonehd "copy.vdi" "source.vmdk" --format vmdk
(Don’t forget to delete extraneous copies, these files take up a lot of space)
The virtual machine should now have the new resized attached to it and it should be bootable, but the windows install can still only use the original size. We need to alter the partition to make it use the full disk. For this we need to boot into a live Linux disk with GParted. I used the Ubuntu 12.04 install CD, but GParted also have a live image available if you lack an already downloaded disk. Once you have saved the partition, you can shutdown the live disk and reboot into windows, which now has access to the entire resized hard disk image.
Software and versions used:
Ubuntu 12.04 LTS 64-bit (Xubuntu Desktop)
Xubuntu Desktop 12.04 LTS Live CD
Nothing is quiet as annoying as a misbehaving server. Except loud children. But this post doesn’t deal with loud children, it deals with my misbehaving web server and why I had to set-up this site twice.
The day of my first attempt at a setup was more than smooth. I logged into my server to find it not serving web pages. It was like that 16 year old who serves burgers at the local fast food store, much more interested in doing just enough not to get noticed by the boss and get told to get back to work (The DNS still pointed people to the mail servers at least). I tracked the disagreeableness down to a Virtualmin update not working well on CentOS 5.5. This was not at all the first issue I have had with CentOS. When I first setup the server I had to track down a special repository for php5 support, bind took me over a week to configure to get DNS working and after 6 months I still never got a single email working. But this most recent update killed the server. It had slow speeds at best, internal server errors as a norm and just plain disappearing server syndrome (DSS should not be confused with CSS) at worst. Considering that the server does host a few business’s worth of websites, that was just not an option.
I decided to re-install the server with a newer OS that had full support for Virtualmin. Ubuntu 12.04 was the best fit. Since I am using Ubuntu at work for PHP development I have a pretty good feel for the server stack so if something goes wrong I should be able to get it going again quickly. I am still not sure I want Ubuntu as my main server’s OS though, but until it proves itself inept, it should work.
Linode is quick about rebuilds. It takes over 5 minutes for the server to shutdown, but only 30 seconds for Linode to reconfigure and boot into a fresh Ubuntu install. After the first boot-up, I spend about 10 minutes doing the basic configuration such as static IP, hostname, updates and the like. Virtualmin has a shell script that should do the base install for me, so a quick download and the server is installing. Off to play on the Wii for a few minutes, a watched install never finishes.
When I get back I find the server has finished and is ready to continue. So this means I will need to configure all the packages it has installed right? No, it’s done that, they are all running and are waiting for me. So, something in the default config will leave me wanting? No, I can drop in the config files from the first install, click a few buttons and get right to restoring individual sites.
I can say I was not expecting it to be that easy. All together it took about 20 minutes from shutdown of server to sites being served, and I would guess that if you excluded the time I spent not looking at the computer, it would be closer to 15, or maybe even 10 given a script to configure the server after first boot.