Friday, April 17, 2009

Can I speak with root?

Once again... this is not a very exciting post. Unless you are having to re-install a Linux system because you do not have the root password, then it could be like sex. Maybe just a piece of candy but you get the idea.

First get the installation media for said system. In this example it is a Red Hat 4.6 or 5.1 system. Then perform the following:
1. Boot from the media. When it comes up with the installation prompt type "linux rescue"
2. The system will continue to boot and ask about the network interface - it is not needed
3. When it asks about mounting the installation allow it to mount with read-write

Now for the fun part.. ok as fun as it gets

4. The hard drive installation will be under /mnt/sysimage
5. Change to /mnt/sysimage/etc and then edit shadow with vi
6. Find the root entry in the shadow file it will look like:

root:Ep6mckrOLChF.:10063:0:99999:7:::

7. Change the line in the file to look like the following:

root::10063:0:99999:7:::

8. Save and exit vi, and then reboot the system
9. Voila, no root password.
10. Log in as root and set the password with the passwd command ASAP!

Tuesday, February 10, 2009

What to expect....

Ok when it comes to programming ANYTHING I am pretty slow. I needed to change the firewall ruleset on quite a few ESX servers and it seemed like a script was in order to make this change for me. However, since I could not get the Opsware client to run a script remotely (that was part of the problem) i needed to figure out an alternative method.

Enter EXPECT.. I had heard it mentioned before but not really understood what it did. Basically you can open a connection to another system and if you can tell the script what to "expect" then it will know what to send it in return.. pretty cool huh.. This is the part where my wife's eyes glaze over.

Basically what I was doing is this...

spawn ssh some_user@somemachine.com
expect "someuse@somemachine's password:"
send password\r
expect "someuser@somesmachine"

And so on.. you get the idea. BUT.. is there not always a but... the issue I was having was that the prompt was on a VMware ESX server and looked like [usename@hostname username]$. I entered the text verbatim so that the expect showed the brackets etc. It puked. But by removing the brackets and only going to the end of the first word it works. Example..
expect "someuser@hostname" works but expect "[usename@hostname username]$" does not. Go figure. So I am going to stop while I am ahead today and revel in my glory....

Just rember... You Stay Classy San Diego.

Wednesday, January 21, 2009

Backup a minute..

Ok.. another yawner of a post but hey that is me. I am working on process of backing up the VM's in an environment and making it as quick to recover as possible. In my search I ran across a product called esXpress v3.1. It is pretty cool (ok as cool as VM software can be). It does a couple things:

1. It will put a VM into "Snapshot Mode" and then perform a backup of the VMDK.
2. It can put the VMDK backup to SMB/FTP or SSH.
3. After it is done it will remove the snapshot.

THIS IS DONE WHILE THE VM IS RUNNING! HOW COOL IS THAT!

Oh and I did not mention the best part. The software is FREE! Now there are additonal features such as being able to make backups local and remote at the same time, having additional helper machines, encryption and other things.

Check it out at www.esxpress.com

Thursday, January 8, 2009

My Friend CRON...

OK another dry post but hey.. this is not the Life and Times of Someone Exciting.. sorry. I was at work minding my own business when I realized that my little automated email was not there waiting in my inbox from several servers on Mondays when I came in. (Maybe it had a "Case of the Mundays" as described in the movie Office Space) Computers are like Marines. They are not supposed to choose what orders they follow and what ones they do not. I began to investigate.


Looking into the cron log (/var/log/cron) I noticed that NONE of the CRON jobs were running. I am on to something. I looked into the messages log and sure enough there was an entry "Authentication token is not longer valid; new one required". Clear as mud, of course. So I went to the worlds User Manual.. Google. It showed that there was an issue with the root user id. Huh? I just used it. Logging into the console with the root user id, I was greeted with a message that the id was aged out and would have to be changed! I DID NOT GET THIS WHEN I SU to the ROOT ACCOUNT! I changed the password and restarted the crond service. All good now..

As usual, I hope someone benefits from my stupidity.