Monday, August 31, 2009

For watching some command output after time intervals

watch -n 1 "cat /proc/meminfo | grep MemFree"

ssh login without a passwd

Let say you want to access to a machine with IP 10.0.0.4, and make sure you have command ssh, ssh-keygen, ssh-copy-id.

First, generate the key, the key will be used to open the remote machines door.

ssh-keygenYou will see something like that

Enter file in which to save the key (/home/myname/.ssh/id_rsa):Whatever it appears just press enter until it ends, press enter for passphase as well.

Okay, the key will be generated, something looks like ~/.ssh/id_rsa.pub

Copy over the key to remote machine, and enter your password

ssh-copy-id -i ~/.ssh/id_rsa.pub mysurface@10.0.0.4Done. Now you can ssh 10.0.0.4 with username mysurface without password.

ssh mysurface@10.0.0.4

Wednesday, August 26, 2009

Taglist info in vim

1) Download taglist plugin from http://vim-taglist.sourceforge.net/
2)Unzip in $HOME/.vim directory
3)Open a vim editor and type :TListToggle

You should see a Tag List Wiindows at your left side. This will contain info about all the functions , variables, macros etc. Very useful

Make your vim competent with other IDE's

Simple File Sharing Mechanism between machines

cd _directory_to_share_
python -m SimpleHTTPServer _port_no_

where port_no could be anything like 1234

From the other machine, http://_ip_addr_:_port_no_/

Tuesday, August 25, 2009

Setting up private network

Assumption:

----> M2 <--------------------> M3--
| -----------------------------------------|
M1 ------------------------------------M4


M2 and M3 are servers
M1 and M4 are clients

M1 - 10.18.71.238
M2 - 10.18.71.1
M3 - 10.18.207.1
M4 - 10.18.207.180


Hardware connections
1) All are single homed (They have only one ethernet slot)
2) There are 2 network switches (M1 and M2 are connected to one switch; M3 and M4 are connected to the other switch. These hubs are directly connected so that M2 and M3 are connected
3) All of these switches are just accept and forward type of switches

Configurations

On Clients
M1
1) Assign the ip
ifconfig eth0 10.18.71.238/24
2) Set the default gw as 10.18.71.1 (M2)
ip route flush all
route add net 10.18.71.0/24 dev eth0 ( This means, if you need connection to the local n/w, try anywhere where you find eth0)
route add default gw 10.18.71.1


M4
1) Assign the ip
ifconfig eth0 10.18.207.180/24
2) Set the default gw as 10.18.207.1 (M3)
ip route flush all
route add net 10.18.207.0/24 dev eth0 ( This means, if you need connection to the local n/w, try anywhere where you find eth0)
route add default gw 10.18.207.1

Check: Now M1 should be pingable to/from M2 and M3 should be pingable to/from M4. If these are NOT pinging, something else might be wrong. Resolve this before proceeding further

On servers
M2
1) Assign the ip
ifconfig eth0 10.18.71.1/24
2) Make this as a router
ip route flush all
route add -net 10.18.71.0/24 dev eth0
route add -host 10.18.207.1 dev eth0
route add -host 10.18.207.180 gw 10.18.207.1
echo 1 > /proc/sys/net/ipv4/ip_forward

M3
1) Assign the ip
ifconfig eth0 10.18.207.1/24
2) Make this as a router
ip route flush all
route add -net 10.18.207.0/24 dev eth0
route add -host 10.18.71.1 dev eth0
route add -host 10.18.71.238 gw 10.18.71.1
echo 1 > /proc/sys/net/ipv4/ip_forward

Check : Now M2 --> M3 should be pingable

Now the private network is establised. All machines should be pingable from/to all machines

P.S- Make sure to disable Firewalls of all machines (iptables --flush; iptables -t nat --flush; verify iptables -L and iptables -t nat -L. This should NOT have any entries in them