Sunday, 26 May 2013

How to Setup Chroot SFTP in Linux (Allow Only SFTP, not SSH)



If you want to setup an account on your system that will be used only to transfer files (and not to ssh to the system), you should setup SFTP Chroot Jail as explained in this article.
In a typical sftp scenario (when chroot sftp is not setup), if you use sftp, you can see root’s file as shown below.
If you want to give sftp access on your system to outside vendors to transfer files, you should not use standard sftp. Instead, you should setup Chroot SFTP Jail as explained below.
Non-Chroot SFTP Environment
In the following example (a typical sftp environment), abc can sftp to the system, and view /etc folder and download the files from there.
# sftp abc@xcessl0gycs.com
abc@xcessl0gycs's password:
sftp> pwd
Remote working directory: /home/abc

Thursday, 23 May 2013

What’s the Difference Between 127.0.0.0 and 127.0.0.1?



Sometimes the most elementary of questions yield teachable moments; read on as we delve into how a single digit change between 127.0.0.0 to 127.0.0.1 offers a chance to look at network topology.
The Question
What’s the Difference Between 127.0.0.0 and 127.0.0.1?
I know that both are loopback IPs, but they have another ip mask.
What’s the difference between them? Can they be used interchangeably?
===========================================================================

IPv4 routes
===========================================================================
Active routes:
Destination               Mask          Gateway        Interface Metric
      0.0.0.0          0.0.0.0      192.168.1.1      192.168.1.6     26
[...]
    127.0.0.0        255.0.0.0         On-link         127.0.0.1    306
    127.0.0.1  255.255.255.255         On-link         127.0.0.1    306
What kind of information can we tease out from this table?

Tuesday, 14 May 2013

20+ .htaccess Hacks Every Web Developer Should Know About


Apache's .htaccess(hypertext access) configuration file can be a very powerful tool in a web developer's toolkit if used properly. It can be found in the webroot of your server and can be easily edited using any text editor. In this article I'm going to show you 20 .htaccess hacks and how to use them.
Before I start with this article I'd like to start by saying that abusing the .htaccess file will hurt the performance of your website. The .htaccess file should only be used if you have no other way to achieve certain things.
Make sure to back up your current .htaccess file before applying any of the following hacks.

1. Prevent Hotlinking

Tired of people using your bandwidth by putting the images hosted on your server on their website? Add the following code at the bottom of your .htaccess file to prevent hotlinking.
1Options +FollowSymlinks
2#Protect against hotlinking
3RewriteEngine On
4RewriteCond %{HTTP_REFERER} !^$
5RewriteCond %{HTTP_REFERER} !^http://(www.)?domainname.com/ [nc]
6RewriteRule .*.(gif|jpg|png)$http://domainname.com/img/stop_stealing_bandwidth.gif[nc]
NOTE: The following article explains better methods to "prevent" hotlinking:
Link building secrets by Maurizio Petrone

Monday, 6 May 2013

How to check what we have Installed in Debuian/Ubuntu OS


To check what have install by listing all using dpkg is easy.
dpkg -l
To check whether a package is install also easy.
dpkg -l | grep apache
The command above is some how redundant, because dpkg support wild characters, doing this instead
dpkg -l "apache*"
By doing this, it will also list the package that not install but available in dpkg cache, to install them you can simply apt-get. To indicate the packages installed it shows “ii” and not install shows “un”.

Shell Script File for Checking Package Installed or not Or If not then Install Package - For Ubuntu OS

Dpkg: check that unix package is installed. Bash script: install package if not present

dpkg -s can be used.
Example: is vlc installed?
> dpkg -s vlc|grep installed
Here is some logic in bash script, like installing package if it is not there:
1
2
3
4
5
6
problem=$(dpkg -s vlc|grep installed)
 echo Checking for libxul: $problem
 if [ "" == "$problem" ]; then
      echo "No libxul. Setting up libxul"
      sudo apt-get --force-yes --yes install vlc
 fi

Thursday, 11 April 2013

How to Enable and Disable Root Login in Ubuntu 12.04 TLS

We have recently installed Ubuntu 12.10 Desktop and Ubuntu 12.10 Server, we have nowhere asked to supply root password during installation. Generally in Linux, root user does exist and we need to supply root password during installation. By default root account is disabled in Ubuntu Linux because of security reason and you cannot login as root user directly or su - (Switch User) to become a root. You need to add sudo (superuser do) before actual command if you want to run all administrative commands and you need to supply your password when prompts for password.


Sudo is allowed user to become superuser for temporary to run superuser administrative tasks.
During installation only allow to create new user which has no root ( aka super user) privileges. But same user is allowed to execute sudo commands. Configuring sudo access for users, need to configure /etc/sudoers.
We’ll be covering the usage of SUDO and also we are going to show you tips & tricks to become root user.