Thursday, 11 July 2013

How to setup RDS ( Relational Database Service ) on Amazon

RDS is a separate service on AWS. On creating a new RDS instance , you will get a username, password and a hostname to use it on your application. 

After install RDS point your database towards RDS Or you can install PhpMyadmin in your EBS instance and in its configuration file give RDS details to connect.

You will get following details after you install RDS instance.

DB Version:- Mysql 5.5.27
Instance Class:- db.m1.medium
Allocated Storage: 1024 GB
DB Instance Identifier: rds-ctechz
Master Username: root
Master Password: 12345678
Hostname / Endpoint
:The DNS address of the DB Instance.--- rds-ctechz.ckieen0iiljz.us-east-1.rds.amazonaws.com

# mysql -uroot -p -P3306 -h rds-ctechz.ckieen0iiljz.us-east-1.rds.amazonaws.com


Please check the installation steps below:-

1.
  
 2. RDS-DashBoard
                               
 3. LaunchDBInstance
                               
4. DB-InstanceWizard
                                
5. SelectDB 
                              
6. DBDetails
                              
7. CreatingBDName-and-port
                               
8. DB-Backup-Planning
                             
9. LaunchDB-Instance
                              
10.
                              
11. LaunchingDBInstance
                               
12.                       

13. DB-Description
                             
14. ConfigureDB-SecurityGroups-forAccessingDBInstance
                             
15.
                                
16.
                             
16.1
                               
16.2
                              
16.3
                                
16.4
                                 
17.
                                

Wednesday, 3 July 2013

How to Start and stop daemons via sudo

Problem: you want specific non-superusers to start and stop system daemons
 

Solution: Here we let four our different users to start,stop, and restart web servers. The script for doing so is /etc/init.d/httpd

/etc/sudoers:
User_Alias FOLKS=barbara, l33t, jimmy, miroslav


Cmnd_Alias DAEMONS=/etc/init.d/httpd start, /etc/init.d/httpd stop, /etc/init.d/httpd restart


FOLKS ALL = (ALL) DAEMONS



How to Authorize Password changes via sudo

Problem: you want to permit a user to change the passwords of certain other users.
 

Solution: To permit smith to change the passwords of jones, chu, anf agarwal:

/etc/sudoers:
smith ALL = NOPASSWD: /usr/bin/passwd jones, /usr/bin/passwd chu, /usr/bin/passwd agarwal 


The NOPASSWD tag is optional.


How to Permitting read-only access to a shared file via sudo

Problem: Two or more users want to share a file, some read/write and others read-only.
 

Solution: Create two linux groups, one for read/write and one for read-only users:

/etc/group:
readers:x:300:r1,r2,r3,r4
writers:x:301:w1,w2,w3

 
Permit the writers group to write the file via group permissions:

# chmod 660 shared_file
# chgrp writers shared_file

 
Permit the readers group to read the file via sudo:


/etc/sudoers:
%readers ALL = (w1) /bin/cat /path/to/shared_file

Note: If a file must be writable by a group of teaching assistants but read-only to a group of students. if there were only two users-one reader and one writer - you could dispense with groups and simply let the reader access the file via sudo.

if smith is the reader and jones the writer, and we give smith the following capability:

/etc/sudoers:
smith ALL = (jones) NOPASSWD: /bin/cat /home/jones/private.stuff

then jones can protect her file:

jones$ chmod 600 $HOME/private.stuff

and smith can view it:

smith$ sudo -u jones cat /home/jones/private.stuff


How to Prohibiting Command-line arguments with sudo

Problem: ou want to permit a command to be run via sudo, but only without command-line arguments.

Solution: Follow the pgm name with the single argument :: in /etc/sudoers:

/etc/sudoers:
smith ALL = (root) /usr/local/bin/mycommand ""

smith$ sudo -u root mycommand a b c  ----   Rejected
smith$ sudo -u root mycommand    ----     Authorized

NOTE:
if you specify no arguments to a command in /etc/sudoers, then by default any arguments are permitted.

/etc/sudoers:
smith ALL = (root) /usr/local/bin/mycommand

smith$ sudo -u root mycommand a b c  ----- Authorized
Use "" to prevent any runtime arguments from being authorized.


 

How to run any program in a directory via sudo

Problem: Authorize a user to run all programs in a given directory, but only those programs, as another user.

Solution: Specify a fully-qualified directory name instead of a command, ending it with a slash

/etc/sudoers:
smith ALL = (root) /usr/local/bin/

smith$ sudo -u root /usr/local/bin/mycommand   Authorized
smith$ sudo -u root /usr/bin/emacs             Rejected

This authorization does not descend into subdirectories
smith$ sudo -u root /usr/local/bin/gnu/emacs    Rejected



How to Grant privileges to a group via sudo

Problem: Let a set of users run commands as another user,

Solution: Define a linux group containing those users,

/etc/group:
mygroup:x:1200:joe,jane,hiram,krishna

then create a sudo rule with the %groupname syntax:

/etc/sudoers:
# let the group run a particular program
%mygroup ALL = (root) /usr/local/bin/mycommand arg1 arg2
# give full superuser privilages to the group
%mygroup ALL = (ALL) ALL