Local SVN

Step 1: Installation of Packages.
The Two packages needed for svn is as below

#yum install -y subversion mod_dav_svn
* httpd package needs to be installed.

Step 2: Create and configure Subversion Repository.
The steps that I am going to follow are as follows.
1. Create subversion directory under /usr/local/ and change the owner and group as apache.apache.

#mkdir /usr/local/subversion
#chown –R apache.apache subversion/  #subversion and inside all the directories will have                                                                apache.apache ownership

Here the subversion folder will contain all the repository that we are going to create now and in future.

2. Create repository by using svnadmin command as follows.

#svnadmin create myproject1
* Here my repository name is myproject1

3. Touch svnupload.sh file and add following lines and save.
#vim svnupload.sh   
       
#!/bin/bash
home_dir=/usr/local/subversion/myproject1/
svnlook changed /usr/local/subversion/myproject1 >> /usr/local/subversion/myproject1/test.txt
cat /usr/local/subversion/myproject1/test.txt| sed 's/^[A-Z]//g'| sed 's/^  //g' >> /usr/local/subversion/myproject1/upload.txt
for i in `cat /usr/local/subversion/myproject1/upload.txt`;do svn export --username "svn" --password "svn123" --no-auth-cache http://localhost/myproject1/$i /var/www/html/$i --force;done
for i in `cat /usr/local/subversion/myproject1/upload.txt`;do chown -R apache:apache /var/www/html/$i ;done
for i in `cat /usr/local/subversion/myproject1/upload.txt`;do chmod -R 775 /var/www/html/$i ;done
cat /usr/local/subversion/myproject1/test.txt |grep D | sed 's/^[A-Z]//g'| sed 's/^  //g' >> /usr/local/subversion/myproject1/delete.txt
for i in `cat /usr/local/subversion/myproject1/delete.txt`;do /bin/rm –rf /var/www/html/$i ;done
> /usr/local/subversion/myproject1/test.txt
> /usr/local/subversion/myproject1/upload.txt
> /usr/local/subversion/myproject1/delete.txt

 # chmod +x svnupload.sh           #give this file a execute permission   

4. Go to the hooks directory under repository.

#cd /usr/local/subversion/myproject1
#cd hooks
#cp post-commit.tmpl post-commit --- copy post-commit.tmpl as post-commit
#vim post-commit --- open post-commit file

#REPOS="$1"                                                                 #comment this line
#REV="$2"                                                                    #comment this line
#mailer.py commit "$REPOS" "$REV" /path/to/mailer.conf     #comment this line
/bin/sh /usr/local/subversion/myproject1/svnupload.sh        #add this line

#chmod –R 775 hooks/                  #give hooks directory and sub-files 775 permission

Step 3: Configuring subversion.

#cd /etc/httpd/conf.d/
#vim svn.conf --- touch new file say svn.conf and add following line.

<Location /myproject1>
DAV svn
SVNPath /usr/local/subversion/myproject1
AuthType Basic
AuthName "Subversion repositories"
AuthUserFile /etc/httpd/conf.d/.htpasswd
Require valid-user
</Location>

Now create user for subversion say test1

#htpasswd –cm /etc/httpd/conf.d/.htpasswd test1

Now restart Apache service.

Take checkout of the repository on your local machine and try to upload code through local svn.

http://<server-ip-address>/myproject1


For More Details Refer Link What is SVN? && How does SVN work?

How to Create VPC, Subnets, Internet Gateway and Nat Gateway

1. Go to VPC Dashboard under AWS console after you log in.



2. Creating VPC.
Click on Create VPC on VPC dashboard.
Now provide the details as per the requirements.
Here I have Given Name Tag as “Pranav-VPC”.
CIDR block as 192.168.0.0/24 i.e. total 254 host IP’s possible.
Remaining field kept default as it is. 



3. Creating subnets.
Here I am going to create two subnets, one is for Public facing servers and the other one is for Private servers.
First, create a Public subnet with the details as follows.
Name Tag: Public-1a (Depends on you)
VPC: Select VPC created in above step
Availability Zone: us-east-1a (Depends on you)
CIDR block: 192.168.0.0/25 i.e. 128 host IP’s are possible starting from 192.168.0.0 - 192.168.0.127 



Now we create a Private subnet with the details as follows.
Name Tag: Private-1a (Depends on you)
VPC: Select VPC created in the previous step
Availability Zone: us-east-1a (Depends on you)
CIDR block: 192.168.0.64/25 i.e. 128 host IP’s are possible starting from 192.168.0.128 - 192.168.0.255




For More detailed subnet calculation refer http://www.subnet-calculator.com/ 

4. Creating Route tables.
When we create VPC, a default route table associated with that VPC gets created automatically and it is the main route table for that VPC.
Let’s name it as a “Private-RT”.



Create one more route table and name it as “Public-RT”
Associate this route table with our VPC “Pranav-VPC”.



5. Subnet association with route tables.
Under Route tables select “Public-RT”, go to Subnet Associations tab and select public subnet to associate with it.



Similarly select route table “Private-RT”, go to Subnet Associations tab and select private subnet to associate with it.



6. Creating Internet Gateway.
Internet Gateway will be used to route internet bound traffic from the VPC to the internet. 
Go to the Internet Gateway on left side of the dashboard.
Click on Create Internet Gateway and provide Name tag as say “Pranav-IGW”


After creation, click on to Attach to VPC in order to attach the Internet Gateway to VPC say “Pranav-VPC”.  



7. Associating Internet GW with a public subnet.
A public subnet is considered public when there is a route available in the associated route table to the Internet Gateway.
Go to the Route Tables on left side of the Dashboard.
Select Public subnet i.e. “Public-RT” in this case.
Go to the Routes tab and click on add another route.
Add 0.0.0.0/0 at the Destination field and select Internet GW i.e. “Pranav-IGW” at the Target field and then save.


8. Creating NAT Gateway.
Network address translation (NAT) gateway enables instances in a private subnet to connect to the Internet or other AWS services, but prevent the Internet from initiating a connection with those instances.
Go to the “Nat Gateways” on the left side of the VPC Dashboard, click on Create Nat Gateway.
Provide the necessary details, like subnet and Elastic IP, and create the NAT Gateway. 





9. Associating NAT Gateway with a private subnet.
Now go to the “Private-RT” route table and add the route for the traffic destined for the Internet toward the gateway. 





VsFTP Interview Questions

Q) Active and Passive FTP?
Active and Passive FTP are two modes of connection that FTP runs in. FTP uses two channels between client and server, the command channel and the data channel.
Typically command channel is on port no 21 and data channel is on port no 20. The command channel handles commands and responses, the data channel handles actually transferring files.
The difference between active and passive mode lies in whether server or client initiate the data connection.
In active mode, server initiate data connection with the client after the client has established a connection on command channel.
In passive mode, the client establishes the data connection with the server. 

Reference Link: stackoverflow.com

Active FTP:
1. The client connects to FTP server by establishing FTP control connection on port no 21 of the server.
2. Whenever the client requests data over the control connection the server initiates data transfer connection back to the client.
3. The source port for this data transfer connection is always on port no 20 of the server and destination port is the higher port (greater than 1024) on the client side.
4. Active mode is more secure for the server as it does not require an insecure port to be open at server end because it’s the server that initiates the data connection with the client side.

Passive FTP:
1. The client connects to FTP server by establishing FTP control connection on port no 21 of the server.
2. Whenever the client requests data over the control connection the client initiates data transfer connection back to the server.
3. The source port for this data transfer connection is always on the higher port on the client side and destination port is the higher port on the server side.

Reference Link: http://www.slacksite.com/other/ftp.html

Q) Restrict user to their home directory?