Hasnain Ali Blog

OpenSoruce Telephony and Technology

Archive for February, 2009

Howto: Linux Secure Copy

Posted by hasnain110 on February 23, 2009

Here is a quick howto for copying one file from one machine to another machine using SSH session

Command:

If remote machine’s ssh is running on some different port e.g. 7890

scp -P 7892 filename.tar.gz root@remote-machine-ip:/root/

If remote machine ssh is running on default

scp filename.tar.gz root@remote-machine-ip:/root/

Posted in Uncategorized | Leave a Comment »

Linux kill user process

Posted by hasnain110 on February 16, 2009

Found it few days back so sharing it here:

kill -9 `ps -u <username> -o ”pid=”`

Where <username> should be the user you want to kill along with all its running processes

Posted in Uncategorized | 1 Comment »

Google Andriod Features

Posted by hasnain110 on February 15, 2009

Features

**Specifications taken from Wikipedia

Handset layouts

The platform is adaptable to larger, VGA, 2D graphics library, 3D graphics library based on OpenGL ES 1.0 specifications, and traditional smartphone layouts.

Storage

The Database Software SQLite is used for data storage purposes

Connectivity

Android supports connectivity technologies including GSM/EDGE, CDMA, EV-DO, UMTS, Bluetooth, and Wi-Fi.

Messaging

SMS and MMS are available forms of messaging including threaded text messaging.

Web browser

Main article: WebKit

The web browser available in Android is based on the open-source WebKit application framework.
Dalvik virtual machine
Software written in Java can be compiled into Dalvik bytecodes and executed in the Dalvik virtual machine, which is a specialized VM implementation designed for mobile device use, although not technically a standard Java Virtual Machine.

Media support

Android will support audio/video/still media formats such as MPEG-4, H.264, MP3, AAC, OGG, AMR, JPEG, PNG, GIF.

Additional hardware support

Android can utilize video/still cameras, touchscreens, GPS, accelerometers, and accelerated 3D graphics.

Development environment

Includes a device emulator, tools for debugging, memory and performance profiling, a plugin for the Eclipse IDE.

Market

Similar to the App Store on the iPhone, The Android Market is a catalog of applications that can be downloaded and installed to target hardware over-the-air, without the use of a PC. Currently only freeware applications are supported, although Google has announced plans to allow developers to offer paid applications as well.

Posted in Uncategorized | Leave a Comment »

Howto: Apache .htaccess Password protected directories

Posted by hasnain110 on February 11, 2009

Step # 1: Make sure Apache is configured to use .htaccess file

You need to have AllowOverride AuthConfig directive in httpd.conf file in order for these directives to have any effect.Therefore, my entry in httpd.conf looks like as follows:

<Directory /var/www>
Options None
AllowOverride AuthConfig
Order allow,deny
Allow from all
</Directory>

Save the file and restart Apache
If you are using Red Hat /Fedora Linux:

# service httpd restart

Step # 2: Create a password file with htpasswd

htpasswd command is used to create and update the flat-files (text file) used to store usernames and password for basic authentication of Apache users

htpasswd -c password-file username

where -c means create the password-file

Create directory outside apache document root, so that only Apache can access password file.

# mkdir -p /home/secure/

Add new user called hasnain

# htpasswd -c /home/secure/apasswords hasnain

Make sure /home/secure/apasswords file is readable by Apache web server.

If you are using RedHat and Fedora core, type the following commands :
# grep -e ‘^User’ /etc/httpd/conf/httpd.conf

Output:

apache

Now allow apache user apache to read our password file:
# chown apache:apache /home/secure/apasswords
# chmod 0660 /home/secure/apasswords

Now our user hasnain is added but you need to configure the Apache web server to request a password and tell the server which users are allowed access.

Create a directory /var/www/docs if it does not exist:
# mkdir -p /var/www/docs

Create .htaccess file using text editor:
# cd /var/www/docs
# vi .htaccess

Add following text:

AuthType Basic
AuthName “Restricted Access”
AuthUserFile /home/secure/apasswords
Require user hasnain

Step # 3: Test your configuration

Fire your browser type url http://yourdomain.com/docs/ or http://localhost/docs/ or http://ip-address/docs

Posted in Linux | Leave a Comment »

Howto: Reset MYSQL root password

Posted by hasnain110 on February 11, 2009

  1. Stop mysqld and restart it with the --skip-grant-tables --user=root options (Windows users omit the --user=root portion).
  2. Connect to the mysqld server with this command:
    shell> mysql -u root
  3. Issue the following statements in the mysql client:
    mysql> UPDATE mysql.user SET Password=PASSWORD('password') WHERE User='root';
    mysql> FLUSH PRIVILEGES;
  4. You should be able to connect using the new password.

Posted in Linux | Leave a Comment »

Linux Serial Consoles for Servers and Clusters

Posted by hasnain110 on February 10, 2009

The more Linux servers you’re responsible for, the more that serial consoles can save you money, space and headaches by easing remote administration duties.

Required: Serial/Console Cable

Bootloader Configuration: GRUB

GRUB is a flexible bootloader with excellent support for serial consoles.

Can be found under /etc/grub.conf

Listing 1. An Ordinary grub.conf File

# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub
# after making changes to this file
# NOTICE:You have a /boot partition.
#        This means that all kernel
#        and initrd paths are relative
#        to /boot/, eg.
#        root (hd0,1)
#        kernel /vmlinuz-version ro root=/dev/hda6
#        initrd /initrd-version.img
#boot=/dev/hda
default=0
timeout=10
splashimage=(hd0,1)/grub/splash.xpm.gz
title Red Hat Linux (2.4.20-8)
        root (hd0,1)
        kernel /vmlinuz-2.4.20-8 ro root=LABEL=/
        initrd /initrd-2.4.20-8.img
You need to add this console=ttyS0,9600n8 right after LABEL=/

Listing 2. A grub.conf File That Supports Serial Console

#boot=/dev/hda
# Options added for serial console
serial  --unit=0 --speed=9600 \
        --word=8 --parity=no --stop=1
terminal --timeout=10 serial console
default=0
timeout=10
title Red Hat Linux (2.4.20-8)
        root (hd0,1)
        kernel /vmlinuz-2.4.20-8 ro \
                root=LABEL=/ console=ttyS0,9600n8 
        initrd /initrd-2.4.20-8.img
Next time you reboot the server with appropriate setting in windows Hyper terminal
 you should get the the console output… and you are done !!!
 And your done !!!

Posted in Linux | Leave a Comment »

Nokia SIP settings for Asterisk

Posted by hasnain110 on February 10, 2009

Asterisk Configuration for Nokia SIP Phone

Service Profile: IETF

Default Access Point: should be any working wifi

Public Username: sip:your-sip-user-id@asteriskip

Use Compression: NO

Registration: When Needed

Use Security: NO

Proxy Server: No configuration required here

Registrar Server

     Registrar serv. Addr. : sip:asteriskip

     Realm: Asterisk

     Username: your sip username here

     Password: your sip password here

     Transport Type: Auto

     Port: 5060

Posted in Uncategorized | Leave a Comment »

Asterisk g.729 and g.723 Codec Transcoding/Pass-Thru

Posted by hasnain110 on February 10, 2009

Given below are the step by step instruction for making Asterisk work as a codec Transcoder

Step 1:

Download suitable codec binaries for your asterisk platform

Step 2:

Restart asterisk to make asterisk load newly installed codec modules

e.g. amportal restart

Step 3:

log into asterisk console asterisk -rvvvv and type this command core show codec and check if you can see newly install codecs

elastix*CLI> core show codecs
Disclaimer: this command is for informational purposes only.
It does not indicate anything about your configuration.
INT    BINARY        HEX   TYPE       NAME   DESC
——————————————————————————–
1 (1 <<  0)      (0×1)  audio       g723   (G.723.1)
2 (1 <<  1)      (0×2)  audio        gsm   (GSM)
4 (1 <<  2)      (0×4)  audio       ulaw   (G.711 u-law)
8 (1 <<  3)      (0×8)  audio       alaw   (G.711 A-law)
16 (1 <<  4)     (0×10)  audio   g726aal2   (G.726 AAL2)
32 (1 <<  5)     (0×20)  audio      adpcm   (ADPCM)
64 (1 <<  6)     (0×40)  audio       slin   (16 bit Signed Linear PCM)
128 (1 <<  7)     (0×80)  audio      lpc10   (LPC10)
256 (1 <<  8)    (0×100)  audio       g729   (G.729A)
512 (1 <<  9)    (0×200)  audio      speex   (SpeeX)
1024 (1 << 10)    (0×400)  audio       ilbc   (iLBC)
2048 (1 << 11)    (0×800)  audio       g726   (G.726 RFC3551)
4096 (1 << 12)   (0×1000)  audio       g722   (G722)
65536 (1 << 16)  (0×10000)  image       jpeg   (JPEG image)
131072 (1 << 17)  (0×20000)  image        png   (PNG image)
262144 (1 << 18)  (0×40000)  video       h261   (H.261 Video)
524288 (1 << 19)  (0×80000)  video       h263   (H.263 Video)
1048576 (1 << 20) (0×100000)  video      h263p   (H.263+ Video)
2097152 (1 << 21) (0×200000)  video       h264   (H.264 Video)

Step 4:

Choose your fav. editor in linux , mine is Vi

vi /etc/asterisk/extensions.conf and add these lines under the [General]

[general]
#include sip_general_additional.conf
bindport =5060         ; Port to bind to (SIP is 5060)
bindaddr = 0.0.0.0    ; Address to bind to (all addresses on machine)
disallow=all
allow=g723
allow=g729

And for your GW settings do the same

[EXGN]
type=peer
host=x.x.x.x

port=5060
disallow=all
allow=g729
;dtmfmode=inband
;dtmf=inband
nat=no
;insecure=very
Now set your Eyebeam to send calls using g.729 codec to asterisk it should work

To check if calls are going into g.729/723 codec run this command on the main console

sip show channels

I hope this should work

Posted in Asterisk | 5 Comments »

howto: Generate Email with SSH access

Posted by hasnain110 on February 10, 2009

Here are few steps to enable the system shoot email when ever someone access the SSH

So lets get started!

1. Login to your server and su to root

2. cd /root

3. pico .bashrc

4. Scroll to the end of the file then add the following:
echo ‘ALERT – Root Shell Access (YourserverName) on:’ `date` `who` | mail -s “Alert: Root Access from `who | cut -d”(” -f2 | cut -d”)” -f1`” you@yourdomain.com

Replace YourServerName with the handle for your actual server
Replace you@yourdomain.com with your actual email address

Note: make sure the system can access internet

Enjoy :)

Posted in Linux | Leave a Comment »

Howto: Adding Swap file in Linux

Posted by hasnain110 on February 10, 2009

To add a swap file:

  1. Determine the size of the new swap file and multiple by 1024 to determine the block size. For example, the block size of a 64 MB swap file is 65536.
  2. At a shell prompt as root, type the following command with count being equal to the desired block size:
    dd if=/dev/zero of=/swapfile bs=1024 count=65536
    
  3. Setup the swap file with the command:
    mkswap /swapfile
  4. To enable the swap file immediately but not automatically at boot time:
    swapon /swapfile
  5. To enable it at boot time, edit /etc/fstab to include:
    /swapfile               swap                    swap    defaults        0 0

    The next time the system boots, it will enable the new swap file.

  6. After adding the new swap file and enabling it, make sure it is enabled by viewing the output of the command cat /proc/swaps or free.

Posted in Linux | 3 Comments »