How to allow only one ip accessing the server through ssh

September 6, 2011

How to allow only one ip accessing the server through ssh


This post explains how to block all ips except one accessing your system through ssh. Here we are using iptables firewall for blocking and allowing  ips. These rules are tested on Centos linux and will work with other linux distros like redhat, fedora, etc.

Suppose you have your main server with ip 192.168.1.10
And you want to allow access from 192.168.1.4 only

Here is the rules :
Initial state [all accept]

root@test [~]# iptables -L
Chain INPUT (policy ACCEPT)
target     prot opt source               destination
Chain FORWARD (policy ACCEPT)
target     prot opt source               destination
Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination
root@test [~]#
See the rules below.

Now writing rules :

root@test [~]# iptables -I INPUT -p tcp -s 192.168.1.4 --dport 22 -j ACCEPT
root@test [~]# iptables -I OUTPUT -p tcp -d 192.168.1.4 --sport 22 -j ACCEPT
root@test [~]# iptables -P INPUT DROP
root@test [~]# iptables -P OUTPUT DROP
root@test [~]# iptables -P FORWARD DROP
root@test [~]# iptables -L

After :
root@cpaneltest [~]# iptables -L
Chain INPUT (policy DROP)
target     prot opt source               destination
ACCEPT     tcp  --  192.168.1.4          anywhere            tcp dpt:ssh
Chain FORWARD (policy DROP)
target     prot opt source               destination
Chain OUTPUT (policy DROP)
target     prot opt source               destination
ACCEPT     tcp  --  anywhere             192.168.1.4         tcp spt:ssh

Thats it. now the server 192.168.1.10 will be only accessible through ssh from 192.168.1.4.
 

How to setup a NTP server client on a redhat linux rhel5 system

September 6, 2011

How to setup a NTP server client on a redhat linux rhel5 system


The following post explains how to setup a  NTP server and client on redhat linux systems like rhel5. It will also work on centos, fedora, Suse linux etc.

[root@server ~]# rpm -qa | grep ntp
ntp-4.2.2p1-9.el5_3.2

NTP Server IP : 192.168.1.19
Client IP     : 192.168.1.60

Client Configuration :
/etc/ntp.conf   - primary conf file.

open the /etc/ntp.conf file and give the IP of the NTP server as follows
[root@work1 ~]# vi /etc/ntp.conf
server...

Continue reading...
 

What is the use of screen command in linux? How to use it?

September 6, 2011

What is the use of screen command in linux? How to use it?


What is the use of  screen command in linux? How to use it? The following post explains it.
Screen is a powerful tool useful for working in a remote environment. You can start a screen and execute the commands inside the screen. So even if the connection goes down between your system and remote system, you can later attach to the screen. The command will be working inside the screen. 

Installation:
#yum install screen

#screen
Then execute t...

Continue reading...
 

How to change the timezone on redhat linux system

September 6, 2011

How to change the timezone on redhat linux system


First of all take the backup of the current timezone settings
mv /etc/localtime  /etc/localtime.bkp

Now. Suppose you want to change the timezone to Asia/Kolkatta
ln -sf /usr/share/zoneinfo/Asia/Kolkatta /etc/localtime

Thats it. It should be fixed now.

Continue reading...
 

How to limit the connections from one ip address using iptables

September 6, 2011

How to limit the connections from one ip address using iptables


The following command will block all the exceeding connections [ more than 3] from any ip address to this machine. This can be used against DDOS attack.
#iptables  -A INPUT -p all   -m connlimit --connlimit-above 3 -j REJECT

Suppose if you want to block only ssh connections, then use the following command.
iptables  -A INPUT -p tcp --syn --dport 22 -m connlimit --connlimit-above 3 -j REJECT

for allowing 2 telnet connections per client...

Continue reading...
 

How to reset user password in mysql in redhat or centos linux

September 6, 2011

How to reset user password in mysql in redhat or centos linux


Resetting the mysql user password in safemode. Lets see how to reset the password of root user in Centos / redhat linux.

Step1 : Stop the mysql service

#/etc/init.d/mysqld stop

step2 : Enter mysql safemode

#mysqld_safe --skip-grant-tables &

Step3 : Change the password

mysql> update mysql.user set password=PASSWORD("NEWPASSWORD") where User='root';

Step4 : Flush the privileges

mysql> flush privileges;

Step5 : Its over. Now you can quit.

mysql>...

Continue reading...
 

How to install and configure phpmyadmin on redhat linux or centos linux

September 6, 2011

How to install and configure phpmyadmin on redhat linux or centos linux


First of all add the rpmforge repository to user system. Explained here

Now :

[root@localhost ~]# yum install phpmyadmin

[root@localhost html]# vi /usr/share/phpmyadmin/config.inc.php

And add the blowfish secret,
$cfg['blowfish_secret'] = 'a8b7dafdferHJHJ^&U^45776TIUuiYc6d';

http://127.0.0.1/phpmyadmin/

Now edit the phpmyadmin configuration file for apache

[root@eastonch /]# vi /etc/httpd/conf.d/phpmyadmin.conf


  Order Deny,Allow
  ...

Continue reading...
 

Websites each system admin should know

September 6, 2011

Websites each system admin should know


To know your public ip. It shows location and other details too.
http://whatismyipaddress.com/

For checking nameservers, mx record, A record, PTR record and other DNS details.
http://www.intodns.com/

Example:
http://www.intodns.com/randeeppr.me

For checking the accessibility of your ip address or url. It gives ping results from many parts of the world.
http://www.just-ping.com/

For checking the domain details such as owner of the domain and contact details.
http:/...

Continue reading...
 

Backing up and restoring mysql databases

September 6, 2011

Backing up and restoring mysql databases


Tacking the back up of a database
mysqldump  -u username -ppassword  database_name > database_name.sql
For example
mysqldump  -u root -pabc123 horde > horde.sql

Restoring the database
mysql database_name < database_name.sql
For example
mysql horde < horde.sql

Restart the mysql
/etc/init.d/mysqld restart

Continue reading...
 

Setting up apache with subversion in Linux

September 6, 2011

Setting up apache with subversion in Linux


Steps for setting up apache with subversion [For debian system]
Step 1. Install apache [here 2.0.63] as
./configure --prefix=/usr/local/apache2 --with-port=2080 --enable-dav --enable-dav-fs --enable-rewrite --enable-so
make
make install
/usr/local/apache2/bin/apachectl start
/* make sure these packages are already installed in your system. Autoconf, libtool, phython 2, libxml, zlib, neon */
Install all packages from synaptic. Neon instructions can be get fro...

Continue reading...
 

Recent Posts