Thursday, August 11, 2011

Security Series - Password Password Password!!!

A strong password policy is one of the most important aspects of your security posture. Many successful security breaches involve simple brute force and dictionary attacks against weak passwords. If you intend to offer any form of remote access involving your local password system, make sure you adequately address minimum password complexity requirements, maximum password lifetimes, and frequent audits of your authentication systems.

Minimum Password Lenght:
By default, Ubuntu requires a minimum password length of 6 characters, as well as some basic entropy checks. These values are controlled in the file /etc/pam.d/common-password, which is outlined below.

password [success=2 default=ignore] pam_unix.so obscure sha512


If you would like to adjust the minimum length to 8 characters, change the appropriate variable to min=8. The modification is outlined below.

password [success=2 default=ignore] pam_unix.so obscure sha512 min=8

Security Series - Where's the "root"?

In Ubuntu, root user account is locked by default. This is done to harden the security features. You can always enable it by using the following command:
#passwd root

Set the password of the user, logout and again login with root user.

Excuse me!!!....where the admin account list in ubuntu.

:) You can find the list of the sudoers in the file /etc/sudoers.
I used to edited it whenever I need some new users (ssh/ftp) to have sudo rights.

Wednesday, August 10, 2011

Easy Understanding - Changing hostname in Linux(Ubuntu)

Hey Guys!!!....this is a common practice when you are testing some applications like bind to configure the DNS Server on your system. Let me provide you some simple steps to change the hostname of the running ubuntu and relative linux distribution.

[root@localhost~:]#hostname new_name
This will set the hostname as new_name. But this gets washed out as soon as the system reboots. So we need to find a permanent fix.... :)

Edit the following files to hardcode the hostname.
[root@localhost~:]#nano /etc/hostname
[root@localhost~:]#nano /etc/hosts

Cheers

Easy Understanding - DNS Server Configuration

DNS Server, nothing but a distributed light weight database which performs name resouleion as per the RFC1034 RFC.

Please find the easy steps to install and configure the DNS Server on the Ubuntu System
Step 1:
Install Ubuntu dapper, or use your WORKING installation.
[root@localhost~:]#apt-get install bind9

Install dnsutils (which includes "dig")
[root@localhost~:]#apt-get install dnsutils

Step 2:
Confguration of the DNS Server - There a many ways to configure BIND9. Some of the most common configurations are a
Caching nameserver
Primary master(pdns) and
Secondary master(sdns)


Caching Server - When configured as a caching nameserver BIND9 will find the answer to name queries and remember the answer when the domain is queried again.

Primary Master Server - As a primary master server BIND9 reads the data for a zone from a file on it's host and is authoritative for that zone.

Secondary Master Server - In a secondary master configuration BIND9 gets the zone data from another nameserver authoritative for the zone.

Insight - An overview of the bind server.
The DNS configuration files are stored in the /etc/bind directory. The important files in this directory are:
/etc/bind/named.conf - The primary configuration file
[root@localhost~:]#cat /etc/bind/named.conf


The include line specifies the filename which contains the DNS options. The directory line in the /etc/bind/named.conf.options file tells DNS where to look for files. All files BIND uses will be relative to this directory.
/etc/bind/db.root - the root nameservers in the world

Caching Nameserver
The default configuration is setup to act as a caching server. All that is required is simply adding the IP Addresses of your ISP's DNS servers. Simply uncomment and edit the following in /etc/bind/named.conf.options:

Now restart the DNS server, to enable the new configuration. From a terminal prompt:
[root@localhost~:]#/etc/init.d/bind9 restart

Primary Master
In this section BIND9 will be configured as the Primary Master for the domain example.com. Simply replace example.com with your FQDN (Fully Qualified Domain Name).

Forward Zone File
To add a DNS zone to BIND9, turning BIND9 into a Primary Master server, the first step is to edit /etc/bind/named.conf.local:

zone "server.local" {
type master;
file "/etc/bind/db.server.local";
};

Now use an existing zone file as a template to create the /etc/bind/db.server.local file:

[root@localhost~:]#cp /etc/bind/db.local /etc/bind/db.server.local

Edit the new zone file /etc/bind/db.server.local change localhost. to the FQDN of your server, leaving the additional "." at the end. Change 127.0.0.1 to the nameserver's IP Address and root.localhost to a valid email address, but with a "." instead of the usual "@" symbol, again leaving the "." at the end.

Also, create an A record for ns.example.com. The name server in this example:

;
; BIND data file for local loopback interface
;
$TTL 604800
@ IN SOA ns.server.local. root.server.local. (
1 ; Serial
604800 ; Refresh
86400 ; Retry
2419200 ; Expire
604800 ) ; Negative Cache TTL
;
@ IN NS ns.server.local.
@ IN A 192.168.1.10
ns IN A 192.168.1.10


Reverse Zone File
Now that the zone is setup and resolving names to IP Adresses a Reverse zone is also required. A Reverse zone allows DNS to resolve an address to a name.

Edit /etc/bind/named.conf.local and add the following:

zone "1.168.192.in-addr.arpa" {
type master;
notify no;
file "/etc/bind/db.192";
};


Now create the /etc/bind/db.192 file:

[root@localhost~:]#cp /etc/bind/db.127 /etc/bind/db.192
Next edit /etc/bind/db.192 changing the basically the same options as /etc/bind/db.server.local:

;
; BIND reverse data file for local loopback interface
;
$TTL 604800
@ IN SOA ns.server.local. root.server.local. (
2 ; Serial
604800 ; Refresh
86400 ; Retry
2419200 ; Expire
604800 ) ; Negative Cache TTL
;
@ IN NS ns.
10 IN PTR ns.server.local.



Restart the dns server
[root@localhost~:]#/etc/init.d/bind9 restart

Secondary Master
Once a Primary Master has been configured a Secondary Master is needed in order to maintain the availability of the domain should the Primary become unavailable.

First, on the Primary Master server, the zone transfer needs to be allowed. Add the allow-transfer option to the example Forward and Reverse zone definitions in /etc/bind/named.conf.local:

zone "server.local" {
type master;
file "/etc/bind/db.server.local";
allow-transfer { 192.168.1.11; };
};

zone "1.168.192.in-addr.arpa" {
type master;
notify no;
file "/etc/bind/db.192";
allow-transfer { 192.168.1.11; };
};


Next, on the Secondary Master, install the bind9 package the same way as on the Primary. Then edit the /etc/bind/named.conf.local and add the following declarations for the Forward and Reverse zones:

zone "server.local" {
type slave;
file "db.server.local";
masters { 192.168.1.10; };
};

zone "1.168.192.in-addr.arpa" {
type slave;
file "db.192";
masters { 192.168.1.10; };
};

Restart BIND9 on the Secondary Master:

[root@localhost~:]#/etc/init.d/bind9 restart


Done.... :)

Cheers..






vsftp - important steps

Login to the Server with root privileges and execute the command:
[roo@localhost~:]#apt-get install vsftd

This will install the ftp server and start the ftp daemon on your server. Execute the command to check the ftp daemon status

[roo@localhost~:]#/etc/init.d/vsftpd status # Check the ftp daemon status
[roo@localhost~:]#/etc/init.d/vsftpd start # Start the ftp daemon
[roo@localhost~:]#/etc/init.d/vsftpd stop # Stop the ftp daemon

Edit the vsftpd.conf file to configure
[roo@localhost~:]#nano /etc/vsftpd.conf # Edit the ftp configuration file

Uncomment the following line:
Consider changing anonymous_enable=YES to anonymous_enable=NO #unable/disable anons

write_enable=YES # un-comment this
local_enable=YES # un-comment this
chroot_local_user=YES # un-comment this

save and exit. Start the ftp daemon;
[roo@localhost~:]#/etc/init.d/vsftpd start

Please note: You can create the ftp user (which are just like normal user) with the following condition.
1. Add /bin/false shell to the /etc/shells file.
2. Create the user with shell as /bin/false (verify in /etc/passwd)
3. If you want the user not to have the access to the ftp resource, edit the /etc/ftpuser and put the user in this list.

The Very Secure FTP Server - vsftp

File Transfer Protocol (FTP) is a TCP protocol for uploading and downloading files between computers. FTP works on a client/server model. The server component is called an FTP daemon. It continuously listens for FTP requests from remote clients. When a request is received, it manages the login and sets up the connection. For the duration of the session it executes any of commands sent by the FTP client.

Access to an FTP server can be managed in two ways:

1. Anonymous
2. Authenticated

In the Anonymous mode, remote clients can access the FTP server by using the default user account called "anonymous" or "ftp" and sending an email address as the password. In the Authenticated mode a user must have an account and a password. User access to the FTP server directories and files is dependent on the permissions defined for the account used at login. As a general rule, the FTP daemon will hide the root directory of the FTP server and change it to the FTP Home directory. This hides the rest of the file system from remote sessions.

vsftpd - FTP Server Installation

vsftpd is an FTP daemon available in Ubuntu. It is easy to install, set up, and maintain. To install vsftpd you can run the following command:
[root@localhost~:]#apt-get install vsftpd

Anonymous FTP Configuration

By default vsftpd is configured to only allow anonymous download. During installation a ftp user is created with a home directory of /home/ftp. This is the default FTP directory.

If you wish to change this location, to /srv/ftp for example, simply create a directory in another location and change the ftp user's home directory:
[root@localhost~:]#mkdir /srv/ftp
[root@localhost~:]#usermod -d /srv/ftp ftp

User Authenticated FTP Configuration
To configure vsftpd to authenticate system users and allow them to upload files edit /etc/vsftpd.conf:

local_enable=YES
write_enable=YES

Securing FTP

There are options in /etc/vsftpd.conf to help make vsftpd more secure. For example users can be limited to their home directories by uncommenting:
chroot_local_user=YES

You can also limit a specific list of users to just their home directories:

chroot_list_enable=YES
chroot_list_file=/etc/vsftpd.chroot_list

After uncommenting the above options, create a /etc/vsftpd.chroot_list containing a list of users one per line. Then restart vsftpd:

[root@localhost~:]#/etc/init.d/vsftpd restart

Also, the /etc/ftpusers file is a list of users that are disallowed FTP access. The default list includes root, daemon, nobody, etc. To disable FTP access for additional users simply add them to the list.



Tuesday, August 9, 2011

Issssshhhhh....I mistakenly deleted my interface file

Guys..it command that when we work with root privilege, we tend to make mistake. And the most common mistake is deleting the files. I encountered a situation where I was configuring my DNS Server, and mistakenly I deleted the interface file. I thought, I am gone. Since it was a mission critical server.But quickly I realized, let me create one manually and see if it works. And guess what.....It really worked. I never though, I am so witty :).

[root@localhost~:]#nano /etc/networking/interfaces

Add the following line:

iface eth0 inet dhcp

and exit the editor saving the file.

[root@localhost~:]#/etc/init.d/networking restart