Thursday, July 16, 2015

Creating VPN Connection from Home Machine and Connecting via SmartPhone.


As we all know that more than system we used to stick with SmartPhone so what if you want to connect to your home system and pull out from information.


Here you can achieve it, follow the below guidelines:

Creating a VPN Server

First, you’ll need to open the Network Connections window.

Press the Alt key, click the File menu that appears, and select New Incoming Connection.
windows-new-incoming-connection
You can now select the user accounts that can connect remotely. To increase security, you may want to create a new, limited user account rather than allow VPN logins from your primary user account. (Click Add someone to create a new user account.) Ensure the user you allow has a very strong password, as a weak password could be cracked by a dictionary attack.

Select the Through the Internet option to allow VPN connections over the Internet. You can also allow incoming connections over a dial-up modem, if you have the dial-up hardware.
allow-vpn-connections-through-the-internet
You can then select the networking protocols that should be enabled for incoming connections. For example, if you don’t want people connected to the VPN to have access to shared files and printers on your local network, you can uncheck the File and Printer Sharing option.
select-vpn-networking-protocols
Click the Allow access button and Windows will set up a VPN server.
allow-vpn-access-in-windows

Router Setup

You will now need to log into your router’s setup page and forward port 1723 to the IP address of the computer where you set up the VPN server
As I have BELKIN Router so I went to Virtual Server and did this settings. If you have it from some other (TPLINK, NETGEAR, etc) it can be done easily.
Make sure that it is allowed to the use the VPN Connection:
Now one setup you can do to avoid the IP Conflict from the connecting users:

Connecting to VPN Server


Via SmartPhone


Goto Setting -- Under Network (more) -- VPN --> Then Enable the VPN settings:

Note: When enable VPN Setting SmartPhone must have lock screen as PIN no. or Pattern.

Enable VPN should be appear like this:




Tap on the Add VPN




Upon tapping on the Add VPN now you can name it VPN (could be any name), type must be PPTP because the VPN server which you have create it uses PPT Protocol for communicate.

In the Server Address you need to type the IP address of the system for where you have created the VPN Server. Make sure you should what is the IP address is provided from your ISP (You may have to call up your service provider i.e Airtel, Verizon, etc). It is always recommended you should get static IP from your service provider so that connection will be persistent.


Once done then Tap on OK. Now you see that VPN connection is been created in your phone.



So, I have created a VKVPN is available Tap on it connect, then supply the credentials:

Bingo!! That's it You are connected


Now you can do Remote Desktop to your Home system or you can browse the file by using File Explorer in the SmartPhone Device.

As of now I have provided details for Andriod SmartPhones, Stay tuned will be sharing for iOS soon!

Thanks.

Sunday, July 12, 2015

Unix Shell Script for Viewing Size of Specific Files as well as with Addition of Similar Files



echo "This script is to show the size of files as well as collectively addition of similar file for the today and yesterday timestamp."

#Goto the folder where files are located
cd <destinated_folder_structure>

#Below command will list the files with the matching pattern then it will grep for the yesterday date file and size of file is storing in the temp file. Later in second line it doing the addition which will be overrite the temp file.
ls -ltrh <FileMatchingPattern>*txt* | grep "$(date --date="yesterday" '+%b %e')" | awk '{print $6, $7, $9, $5}' > y1.txt
ls -ltrh <FileMatchingPattern>*txt* | grep "$(date --date="yesterday" '+%b %e')" | awk '{total += $5}; END {print total}' >> y1.txt

#Similar activity as first command is doing but it will do for the Today's date
ls -ltrh <FileMatchingPattern>*txt* | grep "$(date '+%b %e')" | awk '{print $6, $7, $9, $5}' > t1.txt
ls -ltrh <FileMatchingPattern>*txt* | grep "$(date '+%b %e')" | awk '{total += $5}; END {print total}'>> t1.txt

#If you have more than one file pattern then you show them collectively. Let's assume below is another pattern and want to show it.

ls -ltrh <FileMatchingPattern>*txt* | grep "$(date --date="yesterday" '+%b %e')" | awk '{print $6, $7, $9, $5}' > y2.txt
ls -ltrh <FileMatchingPattern>*txt* | grep "$(date --date="yesterday" '+%b %e')" | awk '{total += $5}; END {print total}'>> y2.txt

ls -ltrh <FileMatchingPattern>*txt* | grep "$(date '+%b %e')" | awk '{print $6, $7, $9, $5}' > t2.txt
ls -ltrh <FileMatchingPattern>*txt* | grep "$(date '+%b %e')" | awk '{total += $5}; END {print total}'>> t2.txt


cat y1.txt > final.txt
cat t1.txt >> final.txt
cat y2.txt >> final.txt
cat t2.txt >> final.txt

#So if you want to see on the screen

cat final.txt

#If you want to mail the results

mail -s "Today and Yesterday File Size" abc@mail.com -c xyz@mail.com < final.txt

#If you wish you can delete the temporary generated file

rm -f y1.txt t1.txt y2.txt t2.txt final.txt


Save this file with .sh or .ksh extension and make it shell script and be run by ./<filename>.sh

After saving this file you may have to give permission to run so execute the below command
chmod 755 <filename>.sh

That's it.

Please leave your comments.

Thanks.