Harry Sukumar's Weblog

Archive for December, 2007

Setting Up Multiple Virtual IP’s on a Single NIC-CentOS

Posted by hsukumar on 17/12/2007

In Linux you can bind multiple Virtual IP addresses on a single NIC. This is usually done in case you are using your linux machine as a webserver and is hosting multiple domains (IPbased) and you want to bind each domain to a unique IP address. This is how it is done.

Copy file:$ cp /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-eth0:0

$ Vim /etc/sysconfig/network-scripts/ifcfg-eth0

O/P____

[root@localhost ~]# more /etc/sysconfig/network-scripts/ifcfg-eth0
# nVidia Corporation nForce2 Ethernet Controller
DEVICE=eth0
BOOTPROTO=dhcpNETMASK=255.255.255.0
BROADCAST=192.168.2.255
NETWORK=192.168.2.0
HWADDR=00:0C:76:90:B4:63
ONBOOT=yes

Edit file /etc/sysconfig/network-scripts/ifcfg-eth0:0 Change the file

DEVICE=eth0:0
BOOTPROTO=dhcpNETMASK=255.255.255.0
BROADCAST=192.168.2.255
NETWORK=192.168.2.100( add what ever you feel like as long as it is not on the network)
HWADDR=00:0C:76:90:B4:63
ONBOOT=yes And lastly, restart the networking service. If you are using RedHat, CentOS, Fedora then it is as simple as : # service network restart

Try to ssh to this machine within the network and if you can reach to this (192.x.x.x) machine then it means you have successfully configured your virtual network card J

Posted in CentOS | 1 Comment »

RSA Public/Private key pair-password less authentication

Posted by hsukumar on 17/12/2007

SSH is often used to login from one system to another,

 

$ ssh username@machinename

This will work very nice but it is not very secure but secure enough

RSA or Keyless Authentication is based on Public Key Infrastructure

 

The way we to do this

 

Lets say we are currently logged into machine 192.168.1.1

$ ssh-keygen –t rsa (enter)

Enter file in which to save the key (/root/.ssh/id_rsa): ( Just enter don’t change this

leave it as default as it works very well with out change )

Enter passphrase (empty for no passphrase):

Enter same passphrase again:

Your identification has been saved in /root/.ssh/id_rsa.

Your public key has been saved in /root/.ssh/id_rsa.pub.

The key fingerprint is:

fc:12:ea:86:a4:a5:2b:ce:02:9a:4d:ec:7c:ae:9e:8a

 

$ cd /root/.ssh/

$ scp or sftp ( I will use scp as it is non interactive and all I need to do is jut use it once)

$ scp id_rsa.pub root@destination machine:~/.ssh/

$ ssh root@destinationmachine

$ cd ~/.ssh/

$ cat id_rsa.pub >> authorized_keys ( create authorized_keys files if it doesn’t exists )

 

That’s it all done and well done!!!!

 

You should now be able to log on from your local machine to destination machine with out any password, Just to let you know this is more secure connection than normal password, as password authentication can be easily broken with the help of dictionary attack

 

Hope you have fun doing this!!!

Posted in General Linux | Leave a Comment »

Share Linux

Posted by hsukumar on 05/12/2007

Configure Apt Sources.List on Ubuntu

So you were playing with your Apt sources.list and somehow ruined it. No matter how hard you try you cannot get it back. Every time you try to install a package you get error messages. Now what?

Don’t despair … I’ve been there and found an easy answer: The Aptitude Source-O-Matic: http://www.ubuntu-nl.org/source-o-matic

All you have to do is go there, fill out three boxes and a new sources.list will be created for you. Here is how to use it.Copy the new sources.list to your clipboard.

Back up your current sources.list, make a new one and start editing.

sudo mv /etc/apt/sources.list /etc/apt/sources.list.old
sudo touch /etc/apt/sources.list
sudo vim /etc/apt/sources.list

Hit i (for insert).

Right click with your mouse button and the contents of your clipboard should appear.

[ESC]wq to save your changes.

Update your sources afterwards:

sudo apt-get update

Hopefully all will now go well.

Posted in General Linux | Leave a Comment »