Friday, May 22, 2009

Secure your browsing with SSH

If security concerns you and you have an SSH client on your laptop, and a reachable SSH server that has access to the web here is a great way of securing your traffic.

This method is very useful especially when surfing on public/unsecured WLANs and will make sure your http traffic is encrypted so some bad guy with a sniffer program cannot read your data.

Please note: that this will only encrypt your data from you to the server you will be forwarding the traffic to, from there to the internet the data will be again unsecured.

From your station run:

$ssh -DN 9999 username@ip-address-of-ssh-server





The -N option tells SSH server side not to open for prompt (this is available on SSH version 2 and later).
The -D options tells SSH to listen on a specific port (9999) and forward the traffic to our server.

This will create a SOCKS proxy on your station.
Next open your browser and set a proxy for: localhost:9999


That's it! From now on the traffic between you and SSH server will be encrypted, so no one on your LAN will be able to decrypt/listen to your valuable traffic.

Thursday, May 14, 2009

Adding another HD on Linux / Unix machine

Have you decided to add another HD to your Linux machine?
This guide will help you understand the procedure step by step.
Let's get started.

First after physical installation and basic BIOS check of the device you would like to see if the OS has recognized the disk.

To see attached SCSI devices,  execute:

[root@jenova media]# lsscsi

You should see the new disk on the next SCSI channel.

To check the disk exists on the system run:
[root@jenova media]#fdisk -l

Next we will run:
[root@jenova media]# fdisk /dev/sdb 

Command action
a   toggle a bootable flag
b   edit bsd disklabel
c   toggle the dos compatibility flag
d   delete a partition
l   list known partition types
m   print this menu
n   add a new partition
o   create a new empty DOS partition table
p   print the partition table
q   quit without saving changes
s   create a new empty Sun disklabel
t   change a partition's system id
u   change display/entry units
v   verify the partition table
w   write table to disk and exit
x   extra functionality (experts only)


If you issue the p command, you will see any partitions that
currently exist on the drive.
You can see by the output above there are
no existing partitions. This drive is un-partitionedd
and unformatted. 
To create a new partition, use the n command.
 
Command (m for help): p

Disk /dev/sdb: 50.0 GB, 50019202560 bytes
255 heads, 63 sectors/track, 6081 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot    Start       End    Blocks   Id  System

Command (m for help): n
Command action
e   extended
p   primary partition (1-4)

Partition number (1-4): 1
First cylinder (1-6081, default 1): 1
Last cylinder or +size or +sizeM or +sizeK (1-6081, default 6081): 6081
 
We can check the partition specifications we just entered
by using the p command again.

Command (m for help): p

Disk /dev/sdb: 50.0 GB, 50019202560 bytes
255 heads, 63 sectors/track, 6081 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot    Start       End    Blocks   Id  System
/dev/sdb1             1      6081  48845601   83  Linux


 
If you messed anything up, you can use the d command
and specify which partition you want to delete.


Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

Now that the partition has been created, you need to format
the drive. The most common Linux formats are ext2 and ext3.
You must specify which partition to format by calling the device
and partition number:

[root@jenova root]# mkfs -t ext3 /dev/sdb1
mke2fs 1.32 (09-Nov-2002)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
6111232 inodes, 12211400 blocks
610570 blocks (5.00%) reserved for the super user
First data block=0
373 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424

Writing inode tables: done                      
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 38 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.

In order to automatically mount a partition, you must edit the /etc/fstab file.
The fstab file tells Linux where to mount all partitions located within the system.

[root@roswell root]# vi /etc/fstab


We will mount the new partition as /media. Remember to create a directory named media, otherwise /etc/fstab won't be able to mount the partition.

The following line will be added to /etc/fstab:
 
/dev/sdb1   /media  ext3   defaults   1 2

Next, issue a simple mount command providing the partition name:

[root@jenova]# mount /dev/sdb1 /media


You're all done! You will be able to access the /media folder immediately and after the machine reboots as fstab will automatically re-mount it for you. If you want to verify the partition is successfully present and mounted, use the following commands:

[root@jenova media]# mount


/dev/sda1 on / type ext3 (rw)
none on /proc type proc (rw)
none on /dev/pts type devpts (rw,gid=5,mode=620)
usbdevfs on /proc/bus/usb type usbdevfs (rw)
/dev/sda2 on /boot type ext3 (rw)
/dev/sdc1 on /export type ext3 (rw)
none on /dev/shm type tmpfs (rw)
/dev/sdb1 on /media type ext3 (rw)

The red line shows our new drive freshly mounted.
You can check the space usage if you issue the following command.

[root@jenova media]# df -h


Filesystem            Size  Used Avail Use% Mounted on
/dev/sda1             8.3G  2.4G  5.5G  30% /
/dev/sda2              99M   26M   69M  27% /boot
/dev/sdc1              16G   13G  2.3G  85% /export
none                  250M     0  250M   0% /dev/shm
/dev/sdb1              46G   33M   44G   1% /media