Linux How to force a user to logoff

Linux – How to force a user to logoff

1. Fine User sessions

>>> who -u;
user terminal date time user-process-id ip-address
--- -------- --------- ---------------- ----------
test pts/1 2014-09-11 01:05 01:02 59297 (192.168.2.4)
farooq pts/6 2014-09-11 02:08 . 379 (192.168.2.1)

2. Kill a user session


>>> kill -9 user-process-id;


>>> kill -9 379;

Advertisements
Tagged with: , , ,
Posted in Cloud Computing, Linux, Security, Tips and Tricks

How to generate java keystore from ssl certificate

In this article I will guide you how to generate Java keystore from certificate (as get from Godaddy)

Step-1: Combine the Certificate with the certificate Godaddy bundle


[farooqsh.wordpress.com]$> cat yourdomain.crt gd_bundle-g2-g1.crt > yourdomain_com_combined.crt

Note: You can directly use above combine certificate (yourdomain_com_combined.crt) in your Nginx server configuration.

 

Step-2: Generate java keystore from the Certificate
Please use following commands to generate java keystore from certificate.

[farooqsh.wordpress.com]$> openssl pkcs12 -export -in yourdomain_com_combined.crt -inkey yourdomain_certificate_private_key -out key_and_cert.p12

[farooqsh.wordpress.com]$>/usr/local/jdk1.6.0_35/bin/keytool -importkeystore -deststorepass -destkeystore keystore -srckeystore key_and_cert.p12 -srcstoretype PKCS12 -srcstorepass

Note: If the source entry is protected by a password, srckeypass will be used to recover the entry. If srckeypass is not provided, then keytool will attempt to use srcstorepass to recover the entry. If srcstorepass is either not provided or is incorrect, the user will be prompted for a password. The destination entry will be protected using destkeypass. If destkeypass is not provided, the destination entry will be protected with the source entry password.

 

You can now use this ‘keystore’ to secure your Java applications communication (like Tomcat, POP3, IMAP, SMTP or any other service).

Tagged with: , , ,
Posted in Cloud Computing, Java, Linux, Nginx, Security, Tips and Tricks

My Pathfinder Sojourner

My Pathfinder Sojourner‘ is my final year degree project that i have submitted at Hamdard University Karachi as an accomplishment of Bachelor’s of Computer Science degree in 2003.

Let see what i have done at that time (more than a decade ago).

me on google plus+Farooq Sheikh

 

IDEA:

Design and Develop Autonomous Vehicle with Remote Sensing Capabilities by simulating NASA’S PATH FINDER SOJOURNER Vehicle sent for MAR’S Mission.

Initial Outline:

Computer monitors the direction of vehicle remotely through FSK (Frequency Shift Keying) Wireless Link, i.e. to either Left, Right, Angular or Straight. The Vehicle self-decides in selecting direction. Simultaneously, it keeps an eye on an obstacle to avoid the chance of accident using Ultrasonic Range Finder Sensor.

If there is any obstacle sensed then Vehicle self decides its Safest Path of Escape. Besides its present location the Vehicle also remotely transmits back its Environmental Temperature to the computer.

In a nutshell, the vehicle simulates the NASA’s PATH FINDER SOJOURNER vehicle sent on MARS.

Development Tools:

  • Micro-Controller 89C52
  • Visual Basic and Assembly
  • FSK Link
  • Ultrasonic Range Finder Sensor
  • Temperature Sensor
  • Toy Car
  • Stepper Motor
  • Servo Motor

 

Project Description

“My Pathfinder Sojourner” is an autonomous rover with remote sensing capabilities. The Vehicle self governed itself using the inbuilt smart logic of micro controller. The following are the main feature of our project

  • Vehicle monitors it’s surrounding and keeps an eye on an obstacle to avoid the chance of accident using Ultrasonic Ranger Finder Sensor.
  • Whenever obstacle detects Vehicle finds its safest path of escapee through its smart logic using Stepper Motor and Ultrasonic Range Finder Sensor i.e. to turn Left, Right or U turn.
  • Vehicle calculates its surrounding temperature through LM-35 and displays it.
  • Vehicle must send back its status and surrounding temperature in the form of data packet through FSK Link.
  • Computer must receive the data packet correctly through serial port.
  • Data Packet must be parse, so that useful information is available for display
  • Computer display the information with strong GUI (Graphical User Interface)
  • GUI must meet the Engineering Standard.

 

Project Block Diagram

farooq-sheikh-sojourner-blockdiagram

Project Block Diagram

 

Description of Project Block Diagram:

Micro Controller:

It is the heart of our autonomous rover. The smart logic burned in ATMEL 89C52 is responsible to control all the devices attached with it. Its main responsibility is to keep monitoring attached devices and take action whenever essentials. Our micro Controller is responsible to monitor and control the following devices

  • Ultrasonic Range Finder Sensor
    • The Sensor provides a high to low pulse whenever it detects an obstacle in its way.
    • The output of Ultrasonic Range Finder Sensor is connected with the external interrupt pin of 89C52 Micro Controller, which takes action in response of signal.
  • Temperature Sensor

o Micro Controller is responsible to read Temperature Sensor LM35 by energizing ADC0808 Chip.

  • Display System
    • Micro Controller is also responsible to drive temperature, drawn from ADC0808, and display it on the Vehicle Display Unit
  • Stepper Motor Driver
    • Micro Controller is responsible to drive Stepper Motor by sending appropriate pulses to Stepper Motor Driver.
  • Servo Motors Driver
    • Micro Controller is responsible to control both Servo Motors using PWD (Pulse Width Modulation) technique.
  • Serial Communication
    •  Micro Controller is responsible to format and send data packet serially through its in built UART device.
    •  Data included the Vehicle Position and Surrounding Temperature
    •  It is also responsible to control the communication process as well.
  • FSK Transmitter
    • FSK Transmitter is responsible to receive data packet from attached micro controller
    •  It is also responsible to design packet format before transmission.
  •  FSK Receiver
    • FSK receiver is responsible to receive characters and send it to computer serial port using RS232 standard.
  • Computer Interface
    • Computer receives Packet from serial ports.
    • Parse the Packet, so that useful information is available for display
    • Display Information

 

Project Modules

We divide our project into several basic modules, so that we can meet our objective easily.

  • Serial Communication through RS232 Cable
    • One Way Communication between Micro-Controller and Computer
    • Two Way Communication between Micro-Controller and Computer
  • DC Motor and Servo Control
    • Design DC Motor Driver
    • Interface DC Motor Driver with Micro-Controller
    • Control DC Motor Speed through PWM (Pulse Width Modulation) technique.
  • Temperature Sensor Control and Display Unit
    • Study LM35DZ Temperature Sensor
    • Complete Study the ADC0808 A/D Converter
    • Compatible LM35 Voltages with Analog to Digital Converter Input (ADC) Voltages
    • Interface LM35 with ADC0808
    • Control ADC0808 behaviors and its Output Data bus with Micro-Controller
  • Interface A/D output Data bus With Micro-Controller External Data Bus
    • Design software that takes many samples of A/D converter output and display its mean.
    • Ensure final output result
  • Stepper Motor Control
    • Design Stepper Motor Driver for four coils.
    • Interface the Stepper Motor Driver with Micro-Controller
    • Precisely Control Stepper Motor movements through generation half step pattern. (Steps/degree).
  • Ultrasonic Sensor Control
    • Study Ultrasonic Sensor Behavior
    • Interface it with Micro-Controller External Interrupt (~INT0)
    • Control Ultrasonic Behavior through Micro-Controller
  • FSK (Frequency Shift Keying) Link
    • Transmitter /Receiver Hardware
    • Compatible the hardware with Computer and Micro-Controller using Max232 IC
    • Interface it with Micro-Controller and Computer
  • Integration (Alpha Testing)
    • Integrate the following components into one unit and test them
      • Micro-Controller
      • Stepper Motor
      • Ultrasonic Range Finder
      • DC & Servo Control
      •  Temperature sensor with ADC0808
  • One Way Link & Testing
    • Complete Hardware Design and Testing
    • Data Format (Understandable for PC and Controller)
    • Computer End
    • Data Acquisition Software (PC)
    • Data Monitoring Routine

 

Final Hardware Design

sonjourner-hardware-design

Sonjourner Hardware Design

 

Computer Interface

I choose Visual Basic® 6.0 to represent our data on Computer. Visual Basic ® 6.0 supports serial communication with its Active X control MSComm. MSComm allows the program to open/close and setup a serial port. Further I use Measurement Studio of National Instruments and use its Active X controls for Visual representation of our data.

farooq-sheikh-sonjourner-computer-interface

My Pathfinder Sonjourner-Computer Interface

Project Photo Gallery

farooq-sheikh-sonjourner-project-photo-2

1. Initial R/C Car

2. The R/C car with the Cover Off

farooq-sheikh-sonjourner-project-photo-3

3. Study the R/C internal Circuitry

 

farooq-sheikh-sonjourner-project-photo-4

4. Circuitry Removed

farooq-sheikh-sonjourner-project-photo-5

5. Development at Electronic Lab

farooq-sheikh-sonjourner-project-photo-6

6- Serial Communication between Controller and PC

farooq-sheikh-sonjourner-project-photo-7

7- some experiment Conduct at Lab

farooq-sheikh-sonjourner-project-photo-8

8- Stepper motor and Ultrasonic sensor attached mechanically

farooq-sheikh-sonjourner-project-photo-9

9- Initial Working Prototype of my Sojourner

farooq-sheikh-sonjourner-project-photo-10

10- Initial Working Prototype succeed!

farooq-sheikh-sonjourner-project-photo-11

11- Initial Vero Board Development phase

farooq-sheikh-sonjourner-project-photo-12

12- Vero Board Design

farooq-sheikh-sonjourner-project-photo-13

13- Finally Vero Board Design complete after 16hr of working! Thanks

farooq-sheikh-sonjourner-project-photo-14

14- Vero Board debugging and test it’s all circuitry successfully.

farooq-sheikh-sonjourner-project-photo-15

16- Designing Sojourner body and fits all Hardware in it

farooq-sheikh-sonjourner-project-photo-16

17- Testing Sojourner with its full features

farooq-sheikh-sonjourner-project-photo-17

18- My Pathfinder Sojourner in its final stage

farooq-sheikh-sonjourner-project-photo-18

19- Project Completed and successful. Thanks to Almighty!

 

Tagged with: , , , , , , , , , , , , , , , ,
Posted in zProjects

Protection Against OpenSSL Heartbleed bug

The Heartbleed Bug is a recently found (2014-04-07) serious vulnerability in the popular OpenSSL cryptographic software library. This weakness allows stealing the information protected, under normal conditions, by the SSL/TLS encryption used to secure the Internet. Please see this page for more details.

In this post i will guide you how to check if your Linux VM is affected from this Heartbleed Bug. If yes, then how to install latest OpenSSL patched version.

Step:  Check Currently Installed OpenSSL Version

[farooq@]$ openssl version
OpenSSL 1.0.1e-fips 11 Feb 2013

Step:  Check OpenSSL version branch against Heartbleed  vulnerability 

Status of different versions against Heartbleed bug:

OpenSSL 1.0.1 through 1.0.1f (inclusive) are vulnerable
OpenSSL 1.0.1g is NOT vulnerable
OpenSSL 1.0.0 branch is NOT vulnerable
OpenSSL 0.9.8 branch is NOT vulnerable

In this above example ‘OpenSSL 1.0.1e-fips’ is vulnerable against Heartbleed as mention above (OpenSSL 1.0.1 through 1.0.1f (inclusive) are vulnerable).

Alternately, If your VM is publically available, then you can use following online tool to check against Heartbleed

http://filippo.io/Heartbleed/

 

Step:  How to upgrade OpenSSL

I am using CentOS Linux VM to upgrade OpenSSL from source.

1. Download the latest version of OpenSSL from http://www.openssl.org/source/

protection-against-openssl-heartbleed-bug


[farooq@]$ wget http://www.openssl.org/source/openssl-1.0.1g.tar.gz

2. Extract openssl-1.0.1g.tar.gz

[farooq@]$  tar -xvf openssl-1.0.1g.tar.gz

3. Go to source directory

[farooq@]$  cd openssl-1.0.1g

4. Compile, Test and Install

[farooq@]$ ./config shared -–prefix=/usr -–openssldir=/usr/local/openssl
[farooq@]$ make
[farooq@]$ make test
[farooq@]$ make install

5. Done. Now Verify latest Version

[farooq@]$ openssl version
OpenSSL 1.0.1g 7 Apr 2014

6. Finally Restart Services Used by OpenSSL

Examples

[farooq@]$ /etc/init.d/httpd restart #Apache Restart
[farooq@]$ /etc/init.d/sshd restart #SSH Restart
[farooq@]$ /etc/init.d/nginx.sh restart #Nginx Restart

 

 

Tagged with: , , , , , , , , , , , , , , ,
Posted in Cloud Computing, Linux, Nginx, Security

/bin/sh^M bad interpreter — Convert DOS (Windows or Mac) text file to Unix

If you are getting following error

bash: /bin/sh^M: bad interpreter: No such file or directory

Simply use vi and use following command to convert and save DOS (Windows or Mac) text file into Unix format.

:set fileformat=unix
and then Save
:wq

Tagged with: , ,
Posted in Cloud Computing, Linux, Tips and Tricks

How to get loaded JQuery version on the page

How to get loaded JQuery version on the page

Firebug Console: jQuery.fn.jquery;


e.g
>>> jQuery.fn.jquery;
"1.4.2"

How to get loaded JQuery version on the page

How to get loaded JQuery version on the page

Tagged with: , , , ,
Posted in Tips and Tricks, Web 2.0