Archive for January, 2009

Optimize Battery Life on Linux Laptop

When I got my first laptop I went strait for my ubuntu disk and never installed windows on the machine. I didn’t realize how bad my battery life was until my office supplied me with a inspiron D830 (same motherboard, basically the same hardware). The windows machine for my office had about 4.5 hours of battery life, while my Linux machine was topping out around 3.5 hours.

There are some things you can do with your Linux laptop to increase the life of the battery. I will keep editing this post over time as I come across new ways to reduce power consumption.

(more…)

Install (Set up) Xspim MIPS simulator in Ubuntu

Had to recently use xspim for a course in computer architecture.

The program simulates R2000 and R3000 processors, and was written by James R. Larus. The MIPS machine language is often taught in college-level assembly courses.

First you want to grab the required packages:

sudo apt-get install flex bison byacc libx11-dev libxaw7-dev build-essential linux-headers-`uname -r`

Download the xspim simulator from Larus’s website: http://pages.cs.wisc.edu/~larus/spim.html and navigate to the directory you extracted it in.

Now for xspim you need to navigate to the xspim sub directory and simply:

xmkmf
make
sudo make install

Now you will be able to launch the xspim simulator from the terminal by typing ‘xspim’.

xspim

A thing to note about using xspim on your machine: In our course we do most of our demonstrations on the Solaris machines which have Big Endian processors, on my laptop I am using a Pentium T9400, which is x86, which is Little Endian.  There may be some problems with programs that you write, I have not experienced any differences yet. Good Luck!

Resources:

Endianness (Wikipedia)

Install (Set up) Secure SSH on Ubuntu

SSH is fantastic for everything, if I could ssh into my refrigerator and let it know that I wanted milk it would be a perfect world. I need to install openssh on the box next to me for a whole host of reasons, so this is a quick guide on how to set up openssh in a secure manner.

Install and general configuration

Firstly you will want to install the openssh server:

sudo apt-get install openssh-server

After the install we want to change some of the default settings to promote some security through obscurity. First file we will edit is the /etc/ssh/sshd_config. Find the line that says:

#What ports, ips and protocols we listen for
Port 22

Make a change to that port (choose a non-standard port), we dont want to be running on the default port. You might also want to check the following settings:

  • RSAAuthentication == YES
  • Protocol == 2 (make sure this is not a ’1′)
  • PasswordAuthentication == YES (only if you have not done the Key Authentication part below)
  • AllowUsers == make sure the users you want to access the machine are in here
  • PermitRootLogin == NO

*The above checklist has been scalped from TuxTraining

Then restart the sshd server:

sudo /etc/init.d/ssh restart

Now for some security lets configure the /etc/hosts.allow file, add an allow for for all local activity and for ssh from the ip’s you are expecting. This is fine for me on my local network where ip’s are not changing, but for a server that your ssh’ing into from other areas this might not be plausable. Nevertheless this is how my /etc/hosts.allow looks:

ALL : 127.0.0.1
sshd : 10.0.0.2, 10.0.0.4

Now the /etc/hosts.deny file:

ALL : ALL

Key Authentication

When I set up my first server I scoffed at the idea of doing key based authentication because I would be the only user and I had a fairly long key, however go ahead and check your log files for failed authentications and you will see thousands a month. For this reason it is advisable to use key based authentication and ditch passwords alltogether… how long will it take them to guess your user password?

Client

  • If the directory does not already exist then create ~/.ssh
  • Generate the public/private key pair with the following command, make sure to enter a password. If you do not enter a password then anyone who gets a copy of your key can use it:

ssh-keygen -t rsa -b 4096 -f ~/.ssh/id_rsa

  • Now you need to edit the /etc/ssh/ssh_config file by changing the following lines:

IdentityFile ~/.ssh/id_rsa (remove the # to uncomment)

Protocol 2 (Remove the 1 and remove the # to uncomment)

Server

  • If the directory does not already exist then create ~/.ssh
  • Make sure the permissions on the ~/.ssh directory are 700
  • Maybe have to chown the ~/.ssh directory if you created it with the sudo command, this is so you can copy your keys into is.
  • Copy the ‘id_rsa.pub’ file from your client machine to your server, you can use scp for this (run this on your client, you are copying the file Client=>Server):

scp ~/.ssh/id_rsa.pub <user_name>@<server_address>:~/.ssh

  • Now back to the server to put your key into the ~/.ssh/authorized_keys list:

cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys

  • Now you will want to edit the /etc/ssh/sshd_config file by changing the following lines:

Protocol 2 (make sure to remove the 1)

PubKeyAuthentication yes

AuthorizedKeysFile .ssh/authorized_keys

PasswordAuthentication no

ChallengeResponseAuthentication no

UsePAM no

  • Now restart the sshd service and you are set to go:

sudo /etc/init.d/ssh restart

Now you should be good to go. There is all kinds of extra tightening down you can do, but this setup so far has let me sleep at night. Enjoy fantastic cli power!

Resources

The Ultimate SSH Security Tutorial (TuxTraining)

SSH Howto (Ubuntu Documentation)

Install (Set up) Nvidia Binary Driver on Ubuntu

Had two friends recently ask me about how to install the nvidia bin driver under ubuntu. There is instructions on the nvidia site on how to install the driver, however there are some ubuntu/gnome specific things that are not included.

Start off by downloading the driver from Nvidia’s site, this should get placed on your desktop. Now you want to drop into terminal 1 by pressing Ctrl+alt+f1. Now some prep work, if you are on a fresh install of ubuntu you will want to grab the build essentials:

sudo apt-get install build-essential

Now that you have the required material you need to stop your gnome desktop:

sudo /etc/init.d/gdm stop

Next navigate to the driver and run it:

cd ~/Desktop
sudo sh <Name of Nvidia Driver>

It is a strait through install, make sure to answer yes when it asks to run nvidia-xconf so it can re-setup your xorg.config.

Now you can restart the machine or just start gnome desktop back up:

sudo /etc/init.d/gdm start

You should be good to go.

Arrow Keys in Vmware Workstation 6.51 on Ubuntu

On a fresh install of Ubuntu Intrepid Ibex (also Hardy Heron) Vmware Workstation’s arrow keys and some hot keys will not work. This can be easily fixed by running the following command, which will create a config file for vmware workstation that sets the xkeymap.nokeycodeMap value to true.

sudo echo 'xkeymap.nokeycodeMap = true' >> ~/.vmware/config

Restart Vmware Workstation and enjoy!

Install (Set up) NFS on Ubuntu

Next to my workstation I have a second machine built that houses a 2TiB RAID 5 array and a 500GiB drive for virtual machines. Ideally these resources need to be accessed as if they were extensions of my workstation.

The solution to this situation was to set up nfs on both machines then mount the array on my workstation.

On the server nfs has to be set up properly, I choose to use the client’s IP as my authentication method because the machines were connected through a crossover cable and have a separate IP scheme set up for the nfs sharing.

(more…)

Install (Set up) RAID with MDADM (Software Raid)

I am obsessed with disk space, and with that comes and obsession with redundancy. It is a fact that the hard disk drives you purchase will only work for a variable amount of time. Now this might be such a long time that you will upgrade/replace and never have a drive failure, but if you have ever had an unexpected drive failure and lost information then you know how terrible of an experience it is.

I need about 1.5 TiB to be comfortable with the amount of current bits I have, but I had a couple of WD 500AAKS in a machine alread and figured that I would max out the sata ports on a motherboard and use that machine as a dedicated file silo.

For my purposes I have chosen to run RAID 5 so that I can take maximum advantage of my 5 drives storage space and still have a redundant parity.

(more…)

Install (Set up) Secure Messaging with Pidgin Encryption

It is nice to think that we all have personal privacy when carrying on a conversation, however the information  you are sharing with the other individual is sent in a plain text. This means that anyone who has the ability  to ’sniff’ your network traffic can read your conversation with little to no difficulty. Individuals with this  ability might range from IT representatives at an organization you work for  to a knowledgeable person sitting in the coffee shop with you.
Pidgin

I have used Pidgin for several years in windows, and when I made the switch to Linux I was pleased to find it was bundled with the distribution I chose (Ubuntu). Pidgin is a cross platform compatible multi-protocol chat utility that has many useful plugins.
Pidgin Encryption

Pidgin-Encryption is a plugin that transparently encrypts your instant messages using the RSA algorithm.

(more…)

Install (Set up) Verlihub on Ubuntu

Verlihub is a Direct Connect protocol server runs on Linux OS written in C++. It runs on almost all OS (except some problems with Windows) with relatively very low processor-memory-bandwidth usage, and many useful features.

Verlihub will require a MySQL database installed to store much of the operational information, and a directory in which it will write the configuration files.

I am not opposed to compiling from source, however I like to take advantage of the repositories whenever available.

(more…)