Kamis, 26 Maret 2009

Passwordless SSH

So you have a bunch of Ubuntu servers and you use SSH to do administrative tasks on the machines. It is beginning to be a pain to always type the password each time you login to a server. You want a way where you can log straight in without having to type a password. That is where key authentication comes in. You can use a program to generate a public and private key for your computer. You can then distribute your public key to each of your servers and then your authentication will come from the keys and not from a password. Please read through these steps carefully and you can have these useful passwordless SSH logins.
  1. Install OpenSSH on your computer and all of the servers (You probably have done this already).
    sudo apt-get install openssh-server
  2. Generate your public and private keys. When it asks for a passphrase leave it empty.
    ssh-keygen -t rsa
  3. You now need to distribute your public key (~/.ssh/id_rsa.pub) to each servers .ssh/authorized_keys file. This can be done in several ways.
  4. If you have not made the authorized_keys file on the server you can do this:
    scp ~/.ssh/id_rsa.pub username@servername:.ssh/authorized_keys
  5. If you have other entires in the authorized_keys folder then you can use cut and paste between two text editors. Open ~/.ssh/id_rsa.pub in the text editor of your choice on your computer. Open a normal SSH session on the server and open the ~/.ssh/authorized_keys in nano, vi, or any other terminal text editor. Copy the text straight from the text editor on your computer to the terminal window. Make sure that it ends up as one line in the authorized_keys file.
WARNING: Not setting a password on your keys can pose a security risk. IF someone were to get your private key they could pose as YOUR computer and access the servers just like you do. Guard your private key with your life.

You can even set this for other users on the server as well as the root user. It is considered a bad practice to log in as root unless you are doing serious administrative tasks. If you run into problems after copying your public key onto your server, just simply move your keys out of your .ssh folder and then you can login to the server using your password to fix the issue. In that case make sure that your public key was all on one line.

Minggu, 15 Maret 2009

Installing Komodo Edit 5

Here is another useful tip for having a good development environment. Since there are many Integrated Development Environments on the market I have been going through each one to see what I like and don't like. I have tested many different IDEs available for PHP programming and I have come to like Komodo-Edit. This is the light (free) version of the Komodo IDE 5 program. Since this is not available via a repository let me show you how to install this into your Ubuntu system.
  1. Download the latest release for Linux by visiting this link (click the link that says download now).
  2. If you are using the gnome desktop you can right-click and select extract here or you can extract using the tar command.
    tar zxvf Komodo-Edit-5.0.3-2767-linux-libcpp6-x86.tar.gz
  3. Open up a terminal and move to that directory using cd. Mine is on my desktop so the command looks like this:
    cd Desktop/Komodo-Edit-5.0.3-2767-linux-libcpp6-x86/
  4. Now run:
    sh install.sh
  5. When you are asked where you would like to install it go ahead and type the directory to where it should be installed. Personally I put all custom installs into a folder called Software in my home directory:
    /home/myuser/Software/Komodo-Edit-5
  6. Once it finishes you still have one more step, inserting the executable into your PATH variable. This can be done with a simple command:
    sudo ln -s "/home/myuser/Software/Komodo-Edit-5/bin/komodo" /usr/local/bin/komodo
I have tested Komodo Edit on both x86 and x86_64 and it works fine even on the 64 bit system. If you get frustrated with other IDE setups go ahead and check out Komodo Edit, it may be your next best editor. By the way you can also edit Perl, Python, Ruby, Tcl, Javascript, CSS, XHTML, and some template languages besides PHP.

Selasa, 03 Maret 2009

RAID 1 and Ubuntu Server 8.10

Since I have recently acquired another 80 GB drive I decided to put it to good use in one of my older computers. It already had an 80 GB drive and what better way to use two equal size hard drives than to set up a RAID 1 array. For some reason when I used to hear the word RAID I assumed that in order to set that up one would need to know a lot. In all reality, setting up a RAID 1 array was quite easy. Since this computer will be a back-up server to my other computers it is nice to know that even if one drive fails I won't lose my data.

I will assume that the reader knows the basics of installing the Ubuntu Server. First of all you will need to download the Server ISO and burn it to disk. Once you have that, the only other item you will need is a computer to test it out on that is ready to have a RAID 1 array put on it. In order for it to be ready it will need to have at least 2 drives of equal size. If you don't happen to have a physical computer you could set up a virtual host will two small drives of equal size. Either way you will need a system that you can do a fresh install of Ubuntu Server 8.10. The screenshots you will see will be from a virtual machine.

Initial Set-up and the /boot partition
  1. Proceed as normal through the installation steps until you get to the part where you need to partition your drive.
  2. Choose Manual
  3. We want to create these partitions: 100 MB for /boot; 256 MB for swap; the rest for /;
  4. Select the first hard drive.
  5. If it asks you to create an empty partition table choose "Yes."
  6. Repeat four and five for the other drive as well and now you should have something like this.
  7. Now we are going to make the partitions on each drive. Select the first drive to partition it's free space.
  8. Choose create a new partition.
  9. Enter 100 MB for its size.
  10. Choose Primary.
  11. Choose Beginning.
  12. Now select the Use as: option and change it to "physical volume for RAID." Also turn the bootable flag on. (This is going to be the /boot partition remember).
  13. Then choose "Done setting up the partition."
  14. Repeat 8 through 13 for the other drive as well.
Setting up the Swap partition
  1. Now we need to set up the swap partition. Select the "FREE SPACE" on the first drive.
  2. Choose Create a new Partition.
  3. Enter 256 MB for the size.
  4. Choose Primary.
  5. Choose Beginning.
  6. Select the Use as: option but this time choose "swap area."
  7. Select "Done setting up the partition"
  8. Repeat steps 2 through 7 for the other drive.
Setting up the / Partition
  1. You should have a similiar set-up as the screenshot below. We could break our root partition down into /home, /usr, /var, etc. I want this to be simple and easy to do. Once you can do this basic set-up you will know how to do the more elaborate.
  2. Choose the "FREE SPACE" on the first hard disk.
  3. Choose Create a new partition.
  4. Use the default value that is already supplied. In my case it is 8.2 GB. This will use the rest of the disk for the root partition.
  5. Choose primary.
  6. Now select the Use as: option and change it to "physical volume for RAID."
  7. Select "Done setting up the partition."
  8. Repeat steps 2 through 7 for other drive.
  9. You should have a similar screen as below. Go ahead and choose "Configure software RAID." (It's at the top)
Configuring Software RAID
  1. Your next screen will ask you if you are really sure about your partitioning. Choose "Yes."
  2. Now select "Create MD device."
  3. Choose "RAID1"
  4. Now it will ask you how many active devices for the RAID1 array. Since we only have two drives we will leave it at 2 and continue.
  5. Now it asks about spares. We don't have any so we will leave it at 0 and continue.
  6. Now we need to choose the two partitions that are going to mirror each other. In my example it will be /dev/sda1 and /dev/sdb1. Choose both using the space bar to select/deselect and then continue.
  7. That's it. You've created the MD device for the /boot partition. Repeat steps 2 through 6 but choose /dev/sda3 and /dev/sdb3 in the last step.
  8. Once you have created both MD devices you can select "Finish."
Last but not Least
  1. We still have to give those RAID1 devices a mount point and filesystem. Follow the steps below to do it.
  2. Select the partition under RAID1 device #0. Mine says "#1 98.6 MB"
  3. Select the Use as: option and choose Ext3 (or whichever one you want).
  4. Change the Mount point: to /boot
  5. Then you can select "Done setting up the partition."
  6. Now repeat steps 3 through 5 for RAID1 device #1, the 8.2 GB partition. This partition will be mounted to /, which is root.
  7. Once you have these partitions made you can select "Finish partitioning and write changes to disk"
  8. Before it makes the changes it gives a nice warning about destroying data. Choose "Yes" to write the changes to disk.
  9. You may get another screen warning about the kernel not being able to access the RAID devices. Just continue and the base system will install as normal.
Conclusion
That's really all it takes to set up a RAID1 array with two hard disks of the same size. Now you can know that if one of your drives were to fail you would still have all of the data because of the RAID1 array. Back-ups must still be made in the case of the failure of both of the drives. That's why I will use rsync and an external drive. Hope this is useful for everyone!
 
support by: infomediaku.com