Hardening SSH Server In The DMZ(De Militarised Zone)

0 comments

Its good to harden your box which is in DMZ.
What is DMZ?
Ans : DMZ is a De Militarised Zone where we will be keeping our servers, so that they can be access by out side people. Let me explain more about this DMZ. Who are not familiarise(And this activity is most of the time a Network admin work).
1. DMZ is a place where we will be isolate machines from companies local LAN.
2. These DMZ machines will have different IP address range and subnet.
3. The communication between two machines in DMZ is blocked for security reasons.
4. We cannot login to Local LAN machine from a DMZ machine, but we can login to DMZ machine from local LAN(only one way communication from LAN).
5. Ping to these machines will be disabled(most of the companies will do this for security reasons).
6. The way these machines communicate totally depends on network team what type of rule they set on their routers.
7. The security of DMZ machines are more when compared to local LAN machines(in other ways every thing is restricted to DMZ machines).
8. Only required ports are opened on DMZ machines and remaining ports are in closed or reject state(This should be done on system by Linux admin and on network level done by companies network engineer).

Once you keep your Linux machine in DMZ first and far-most thing to do is to secure SSH logins to the server.

In this post we will see some security measures for SSH to be taken when system is kept in DMZ. Most of the SSH settings are located in /etc/ssh/sshd_config (Red hat/Debian based systems).

1. Set Maximum failed login attempts, so after that many login attempts connection to the server is reseted and once again we have to connect to server.
MaxAuthTries 3
Here I have set failed login attempts to 3.

2. Disable root to login through SSH. This is a good option to force the user not to use root user to login to the server
PermitRootLogin no
Here we set it to no which indicates root can not login.

3. We should disable logging of users who donot have passwords.
PermitEmptyPasswords no

4. Allow only users who have passwords.
PasswordAuthentication yes

5. Specify who should access this server. I can say this one is more secure because SSH will allow only the users who are specified here.
AllowUsers test1 test2
Here I have allowed only two users i.e. test1 and test2.

6. Set-up a login banner to give warnings to the users how are logging in to that server
Banner /etc/ssh-banner
Please specify the warning message in /etc/ssh-banner.

Once done the above changes in /etc/ssh/sshd_config file just reload the ssh server.

Note : Don't restart SSH service on production servers. Its not advisable to do it. so in-order to update your changes always use reload option. Most of the services will support reload option with service command.
#service sshd reload

Please share your experience which you feel not mentioned in this post.

  • Like the post? Please Subscribe to free RSS feed to get updates
  • How To Install Oracle On RHEL5?

    0 comments

    The most popular database(DB) software known to man is Oracle. There are some other commercial and open source Databases such as
    1. MS-Sql(from Microsoft)
    2. DB2(from IBM)
    3. PostgreSQL(its a open source SW)
    4. Mysql(my favorate one and good for small/medium organisations)
    5. Sybase
    Etc..

    Do you want to know more about other DB names? Have look at below link, i create a squered link for you.
    Ans :
    http://www.google.com/squared/search?q=mssql&items=mysql&items=oracle&items=PostgreSQL&items=db2&items=njsql
    In this post we will come to know that how to install Oracle on RHEL5?

    Step1 : Before installing Oracle it require following packages to be installed on the machine.
    1. compat-gcc
    2. compat-libstdc++
    3. compat-db
    4. make-3.79
    5. binutils-2.11.90.0.8-12
    6. gcc-3.2
    7. openmotif-2.2
    8. setarch-1.3

    All these packages are there in RHEL5 DVD so you just implement YUM server for easy installation of the above packages, other wise you have to install one by one with rpm command which will create a lot of dependencies.

    Step2 : Set kernel parameters by editing /etc/sysctl.conf or using sysctl -w command. As follows.

    Note : When ever you edit any files take backup of that files before editing those files.
    kernel.shmall = 268435456
    kernel.sem = 250 32000 100 128
    kernel.shmmax = 2147483647

    kernel.shmmni = 4096
    kernel.shmall = 2097152
    fs.file-max = 65536

    net.ipv4.ip_local_port_range = 1024 65000
    kernel.sem=250 32000 100 128
    net.core.rmem_default = 4194304

    net.core.rmem_max= 4194304
    net.core.wmem_default = 262144
    net.core.wmem_max = 262144

    #cp /etc/sysctl.conf /etc/sysctl.conf.org
    #vi /etc/sysctl.conf

    After entering the above values save and exit the file
    or use sysctl -w to edit kernel paramaters.
    Here I will just give one example how to edit sysctl.conf using sysctl -w command.

    Suppose I want to edit kernel.sem value just execute below command.
    #/sbin/sysctl -w kernel.sem=”250 32000 100 128”

    Step3 :
    After editing the file check if any issue is there or not by printing the sysctl content.
    #sysctl -p

    Note1 : Most part of the installation is done by oracle user. Untill and unless specified. Only at the end of installation we require to run two scripts which will
    set path variables.

    Note2 : If you are installing Oracle on remote machine we have to export the display to local machine or we have to take vnc to the remote machine.

    Step4 : Create Group name
    #groupadd dba

    Step5 : Creat oracle user with group equal to dba and home directory equal to
    /oracle
    #useradd -d /oracle -g dba oracle

    Installation :
    Step1 :
    Copy Oracle software to some folder. Change the directory to bin directory as showen below.
    cd /test/database

    Here you will find run Installer script which you should execute in oracle user and this should be done in GUI it self(so in order to execute this command you have to export display or take vnc to remote machine). Here in this document I have taken vnc connection to remote machine where I am installing OS. For those who don't have vnc export display as follows.

    Step2 : Exporting display, you have to execute this command as oracle user on remote machine where you are going to install oracle. And one more thing. Display should be exported to local machine where you are going to preform your installation.
    DISPLAY = system name/ip: 0.0
    Export DISPLAY

    Note : System name/ip in the above display command is the ip/system name of your local machine.
    Image.
































































































































    The above screen shot shows that you have to run the script. And this should be run only by root.

    Step3 : Script to be run by root user.
    [root@test oracle]# /oracle/oracle/product/10.2.0/db_1/root.sh
    Running Oracle10 root.sh script...

    The following environment variables are set as :

    ORACLE_OWNER= oracle

    ORACLE_HOME= /oracle/oracle/product/10.2.0/db_1

    Enter the full pathname of the local bin directory : [/usr/local/bin]:

    Copying dbhome to /usr/local/bin ...

    Copying oraenv to /usr/local/bin ...

    Copying coraenv to /usr/local/bin ...

    Entries will be added to the /etc/oratab file as needed by


    Database Configuration Assistant when a database is created

    Finished running generic part of root.sh script.

    Now product-specific root actions will be performed.

    Once run this as root go to oracle user gui login and say ok.. to exit..




























    Step4 : Now we have to check whether oracle is installed perfectly or not. We have to set ORACLE_HOME variable for oracle user .bash_profile file to export oracle bin directory as follows. So that we can start/stop oracle service with lsnrctl edit .bashrc file for the oracle user.
    $vi ~/.bash_profile

    PATH=$PATH:$HOME/bin

    export PATH
    ORACLE_HOME=/oracle/oracle/product/10.2.0/db_1

    PATH=$PATH:$ORACLE_HOME/bin

    ORACLE_SID=orcl

    export PATH ORACLE_HOME ORACLE_SID
    Save and exit the file. Once done we have to source the .bash_profile file. Then start the oracle service by using below command.
    [oracle@v-itig42 ~]$ lsnrctl start

    LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 05-MAR-2010 07:12:13

    Copyright (c) 1991, 2005, Oracle. All rights reserved.

    TNS-01106: Listener using listener name LISTENER has already been started
    For checking status.
    [oracle@v-itig42 ~]$ lsnrctl status

    LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 05-MAR-2010 07:12:01

    Copyright (c) 1991, 2005, Oracle. All rights reserved.

    Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC3)))

    STATUS of the LISTENER

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

    Alias LISTENER

    Version TNSLSNR for Linux: Version 10.2.0.1.0 - Production

    Start Date 05-MAR-2010 06:10:20

    Uptime 0 days 1 hr. 1 min. 41 sec

    Trace Level off

    Security ON: Local OS Authentication

    SNMP OFF

    Listener Parameter File /oracle/oracle/product/10.2.0/db_1/network/admin/listener.ora

    Listener Log
    File /oracle/oracle/product/10.2.0/db_1/network/log/listener.log

    Listening Endpoints Summary...

    (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC3)))

    (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=v-itig42.persistent.co.in)(PORT=1523)))

    Services Summary :

    Service "PLSExtProc" has 1 instance(s).

    Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
    Service "orcl" has 1 instance(s).

    Instance "orcl", status READY, has 1 handler(s) for this service...

    Service "orclXDB" has 1 instance(s).

    Instance "orcl", status READY, has 1 handler(s) for this service...

    Service "orcl_XPT" has 1 instance(s).

    Instance "orcl", status READY, has 1 handler(s) for this service...

    The command completed successfully

    Step5 : Connect to Oracle sql database(and this should be done only as oracle user).

    [oracle@v-itig42 ~]$ sqlplus /nolog
    SQL*Plus: Release 10.2.0.1.0 - Production on Fri Mar 5 07:22:56 2010

    Copyright (c) 1982, 2005, Oracle. All rights reserved.

    SQL>

    This sql> prompt indicates you have sucessfully connected..

    SQL> conn sys@iasdb as sysdba
    Enter password :
    Connected to an idle instance.
    SQL>
    If the database is not started it will show the messages as connected to idle instance.

    4. To start the database execute
    SQL> startup
    ORACLE instance started.
    Total System Global Area 289406976 bytes
    Fixed Size 1301536 bytes
    Variable Size 262677472 bytes
    Database Buffers 25165824 bytes
    Redo Buffers 262144 bytes
    Database mounted.
    Database opened.
    SQL>

    5. To check the name of the database
    SQL> select name from v_$database;

    NAME
    ---------
    IASDB

  • Like the post? Please Subscribe to free RSS feed to get updates
  • How To Reduce Delay Getting SSH Login Prompt

    0 comments

    Recently we have installed a new RHEL5.4 machine. Its located just few kilometres from our office. But when I have observed at the time of logging in the shell prompt is taking considerable time to appear(though connection is taking a fraction of second, after entering the password its taking more time). So we did some tweeking and found out this is related to DNS. We have to change dns related entries in ssh config file to reduce this delay.


    Note : Be careful when doing this on production servers. This activity may disconnect all the users from the system who are logged in to that machine using SSH

    By default UseDNS option in this file is disable. We have to uncommet this option and then edit this entry to no. As below.. 
    Just search for UseDNS..

    [root@tst ~]#vi /etc/ssh/sshd_config 

    before config
    #UseDNS yes

    After config 
    UseDNS no 

    save and exit the file and then just reload ssh service to take effect what ever changes we did.. 

    #service sshd reload.
     
    Now try to login and observe, delay will be reduced.
    Please share your thoughts on this..

  • Like the post? Please Subscribe to free RSS feed to get updates
  • Archive

    Translate this page

     

    The Linux Juggernaut | Copyright 2006-2009 Surendra Kumar Anne | Surendra's Home Page | Give us feedback how we are doing, Click here