Tuesday, April 28, 2009

Run a Unix/Linux job in the background when you log off

If  you want to log off and go home for somewhere, but you need to run a job that’s going to take a couple of hours? Then use nohup will help you to doing this task.

nohup filename.sh &

Vim commands I'm trying to learn/remember


Here are some vi/vim commands that I need to remember:


Vim Commands


------------


:set autoindent


 :syntax on


 :set all                                     (display the value of all options)


 :set number                            (show line numbers)


 :set hlsearch                          (highlight matching search strings)


 :set ignorecase                     (makes searches case insensitive)


 :browse set                            (set options using a screen-based dialog)


 m{letter}                                  (place mark)


 '{letter}                                    (go to mark)


 R ... <Esc>                             (replace characters until <Esc> is hit)


 :split {file}                                (split window)


 CTRL-Wj                                (move up a window)


 CTRL-Wk                               (move down a window)


 CTRL-Wo                               (make the current window the only window)


 

Basic Rules of a typical Firewall

Kill INVALID packets with illegal combination flags.


$IPTABLES -A INPUT -m state --state INVALID -j DROP


$IPTABLES -A FORWARD -m state --state INVALID -j DROP


 


No restrictions to connections from localhost


 


$IPTABLES -A INPUT -i lo -j ACCEPT


 


 


Reject connections from Outside world to Internal loop back device.


$IPTABLES -A INPUT -d 127.0.0.0/8 -j REJECT


 


 


No restrictions for traffic generating from legit internal addresses


$IPTABLES -A INPUT -i $INTERNALIF -s $INTERNALNET -j ACCEPT


 


 


Incase we have to use IPv6 addresses in your environment uncomment the below line:


#$IPTABLES -A INPUT -p ipv6 -j ACCEPT


 


 


Kill all packets from Outside world claiming to be packets generated from Internal network.


$IPTABLES -A INPUT -i $EXTERNALIF -s $INTERNALNET -j REJECT


 


 


Block ICMP requests.


$IPTABLES -A FORWARD -p icmp --icmp-type echo-request -o $INTERNALIF -j REJECT


 


 


Prevent Ping flood attacks:


$IPTABLES -A INPUT -p icmp --icmp-type echo-request -m limit --limit 1/s -j ACCEPT



$IPTABLES -A INPUT -p icmp --icmp-type echo-request -j DROP

 

Deny pings to local broadcast address:


$IPTABLES -A INPUT -p icmp -d $INTERNALBCAST -j DROP


 


Allow all other icmp


$IPTABLES -A INPUT -p icmp -j ACCEPT


 


 No restrictions to established connections:


$IPTABLES -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT



 

 

Dont forward SMB related traffic. Samba Services are one of the most aimed targets by hackers.


$IPTABLES -A FORWARD -o $EXTERNALIF -p tcp --dport 137 -j REJECT


$IPTABLES -A FORWARD -o $EXTERNALIF -p tcp --dport 138 -j REJECT


$IPTABLES -A FORWARD -o $EXTERNALIF -p tcp --dport 139 -j REJECT


$IPTABLES -A FORWARD -o $EXTERNALIF -p udp --dport 137 -j REJECT


$IPTABLES -A FORWARD -o $EXTERNALIF -p udp --dport 138 -j REJECT


$IPTABLES -A FORWARD -o $EXTERNALIF -p udp --dport 139 -j REJECT


$IPTABLES -A INPUT -i $EXTERNALIF -p udp --dport 137 -j REJECT


 


 


Disable Samba Share


$IPTABLES -A INPUT -p tcp --dport 137 -j ACCEPT


$IPTABLES -A INPUT -p udp --dport 137 -j ACCEPT


$IPTABLES -A INPUT -p tcp --dport 138 -j ACCEPT


$IPTABLES -A INPUT -p udp --dport 138 -j ACCEPT


$IPTABLES -A INPUT -p tcp --dport 139 -j ACCEPT


$IPTABLES -A INPUT -p udp --dport 139 -j ACCEPT


 


Allow all other connections to be forwarded


$IPTABLES -A FORWARD -o $EXTERNALIF -i $INTERNALIF -j ACCEPT


 


Allow replies from established connections :


$IPTABLES -A FORWARD -i $EXTERNALIF -m state --state ESTABLISHED,RELATED -j ACCEPT


 


Allow yourself to be a DHCP server for your inside network


$IPTABLES -A INPUT -i $INTERNALIF -p tcp --sport 68 --dport 67 -j ACCEPT


$IPTABLES -A INPUT -i $INTERNALIF -p udp --sport 68 --dport 67 -j ACCEPT


 


 ftp-data


 


$IPTABLES -A INPUT -p tcp  --dport 20 -j ACCEPT


 


 ftp


$IPTABLES -A INPUT -p tcp  --dport 21 -j ACCEPT


 


 ssh


#$IPTABLES -A INPUT -p tcp --dport 22 -j ACCEPT


 


Telnet


$IPTABLES -A INPUT -p tcp --dport 23 -j ACCEPT


 


 


 DNS  


$IPTABLES -A INPUT -p tcp --dport 53 -j ACCEPT


$IPTABLES -A INPUT -p udp --dport 53 -j ACCEPT


 


 http


$IPTABLES -A INPUT -p tcp --dport 80 -j ACCEPT


 


 POP-3


$IPTABLES -A INPUT -p tcp --dport 110 -j ACCEPT


 


 https


$IPTABLES -A INPUT -p tcp --dport 443 -j ACCEPT


 


VNC Server


$IPTABLES -A INPUT -p tcp --dport 5801 -j ACCEPT


$IPTABLES -A INPUT -p tcp --dport 5901 -j ACCEPT


$IPTABLES -A INPUT -p tcp --dport 6001 -j ACCEPT


 




EXPLICITLY BLOCKING SERVICE PORTS FOR GATEWAY FROM OUTSIDE WORLD


/sbin/iptables -A INPUT -j DROP -i eth0 -p tcp --dport 21        # ftp


/sbin/iptables -A INPUT -j DROP -i eth0 -p tcp --dport 22        # ssh


/sbin/iptables -A INPUT -j DROP -i eth0 -p tcp --dport 23        # telnet


/sbin/iptables -A INPUT -j DROP -i eth0 -p tcp --dport 25        # smtp


/sbin/iptables -A INPUT -j DROP -i eth0 -p tcp --dport 53        # domain


/sbin/iptables -A INPUT -j DROP -i eth0 -p tcp --dport 79        # finger


/sbin/iptables -A INPUT -j DROP -i eth0 -p tcp --dport 80        # httpd


/sbin/iptables -A INPUT -j DROP -i eth0 -p tcp --dport 110       # pop3


/sbin/iptables -A INPUT -j DROP -i eth0 -p tcp --dport 111       # sunrpc


/sbin/iptables -A INPUT -j DROP -i eth0 -p tcp --dport 137       # netbios-ns



Install Joomla how to

It seems that a lot of new Joomla users want to know how to install Joomla. It’s obviously very easy and when I started writing tutorials for Jooma I skiped that step. Of, course that must be the first tutorial but…

I will start as you are used to with a step-by-step tutorial. Before we proceed you need Joomla package. The Joomla package can be found on Joomla Forge and can be downloaded from here . It is better to download the latest version because it has the latest bug fixes and new patches. You will find at the bottom of the Forge page the latest full package. Start download it and let’s prepare to install.

You must decide where to install Joomla on your domain. The following paths can be used: http://www.yourdomain.com or http://www.yourdomain.com/Joomla . You you don’t have anything on your domain I will suggest to install on http://www.yourdomain.com. You can also change http://www.yourdomain.com/joomla to http://www.yourdomain.com/site or anything you want.

After you downloaded the package you must decompress it to your hard drive before upload. Decompress and open your FTP client. Login with your Ftp client to your site and upload all your files in the desired directory.

Until all the files upload let’s prepare our database. Login to your cpanel and go to “MySQL databases”. Serach for the button “add db” and type in the form the name of the new database (ex: joomladatabase). Press “add db” button. The new database is created. Now, let’s add a user to that database. Look for “Add User” button. Type your uservame and a password and press “add User”. (don’t forget the password). The next step is to add the user to our database. Below databases are 2 dropdown spots where you see a user and a database. Select yournew user and database. Below select the desired privileges and press “Adduser to DB”.

Image Image



Wow, finished with our database! You can close now the Cpanel because we don’t need it at this point.

or you can use with phpmyadmin or using command line

mysql -u root -p

password: (your password)

create database joomla; <———– use your databasename

quit:

If the upload is over we can start installing Joomla. Open your browser and type in the adressbar http://www.yourdomain.com or http://www.yourdomain.com/joomla. The browser will load the first page in our installation process. It shoul look like the image below.

Image



If something goes wrong and you don’t see the images above type in your browser http://www.yourdomain.com/installation/index.php. I still the page is stange you must verify if:

  • you uploaded all your files

  • you uploaded your files on another directory of your site

  • you have Apache / SQL / PHP server


Our screen have 3 sections: The first checks that your system is able to run Joomla, the second part are some PHP settings and the thrid part checks several file and directory permissions. All parts must be exacly like our image. If the first 2 are not the same ask your web hosting provider about them and maybe they will make corrections. The 3rd part must be modiied by you. This can be done with your ftp client. You must give the directory permisions (CHMOD) so the files to be writeable.

Image


Image


Image



If everything is ok click “Next” button.

The next screen is Joomla Licence and “Terms and Conditions”. read it and if you agree click the checkbox “I Accept the GPL License” and click “next” button on the top-right.

Image



Next page is the “STEP 1″ in our configuration. We have to fill our database configuration. Your hostname is usually “localhost”. We created before the database, username and password. Now, all you have to do is to fill the spaces with the name of the database, username and password. The MySQL Table prefix can be left “jos_” . If is your first installation click the checkbox “Install Sample data”. Click “Next”. A pop-up window will appear to ask you if all info are correct. Verify again and click “Ok”.

Image



Next page is very simple. Type your Site Name and click “Next”. You can Modify you Site name if you want later in the administration area.

Image



In “STEP 3″ you will confirm your URL, path, email and password. The URL and path are usually right and you don’t need to make modifications. The e-mail and password is your “Super Administrator” e-mail and password. Type your e-mail and a password. Remember the password because you won’t be able to login in the Administrator Section i you forgot it. Your username is by default “admin”. You can change your username, password and e-mail later in the “Administration Section”. If all done press “Next”.

Image



Last Step! You see in this screen your username and password. Also Joomla remember you to delete the “Installation” directory. (Use ftp client for that). Also, you have the configuration file typed. Select all and copy. With your ftp client edit “configuration.php” and type (better “paste”) what is written in this last Step.

Image



That’s all! You can press “View Site” to view your new Joomla Site, or “Administration” to enter in the “Administration Area”.

Hosts.deny auto blocking 127.0.0.1

Problem: 





I am getting the below erro when i tried to connect Remote Connection with my server in Nxserver Log.

Error: ssh_exchange_identification: Connection closed by remote host + nxserver

I stopped the denyhosts removed the entry from hosts.deny then restated denyhosts but “sshd: 127.0.0.1″ keeps getting added to hosts.deny

 

Solution:

Try checking the ufw, type in a shell:

     sudo ufw status

If you have any kind of rule here, then try:

   sudo ufw allow from 127.0.0.0/8

This will allow all to localhost


sanjay's shared items

My Blog List