Saturday, February 20, 2010

Use yubikey for safer and less painful browsing

What is yubikey?
Yubikey is usb powered piece of hardware with one action button to generate OTP (one time passwords).

Main advantages:
- There is no need to remember credentials for different sites on the web. Just plug in the yubikey and press action button which will create random OTP password with unique header number of that particular yubikey.
- It will guarantee user inviolability and thus disable fishing attacks and credential information interception.

Main disadvantages:
- You have to carry it with you :), but you can access your web portals without using it in old fashion way by typing your credentials.

Settings things up:
You need to register your account at KeyGenius:
http://kg.yubico.com/

You can use basic or standard account type. Basic will not ask you for any password when logging and all you need is one touch on your yubikey for every login on the web. You are released of typing. Standard account is more secure. It will ask you on first access for your KeyGenius credentials, and after supplying it you can use yubikey like in basic account for every other portal on the web.

Under your account you need to supply information like username, passsword and domain for every domain and credential information.

So it's like this. You want to login on e.g. facebook.com. You will open facebook in browser. Your username will be remembered by your browser. Instead of typing passwords you plug your yubikey and touch button. Login process will continue automatically. First it will send request to KeyGenius to return real password for facebook and after receiving password browser will log you to facebook.

Browser will need to know how to get password from KeyGenius. That is accomplished with java script which can be installed to browser using GreasyMonkey addon. Script can be found here:
http://kg.yubico.com/keygenius.user.js

And thats it. Enjoy your safe browsing... :)

Database synchronization using TableSyncer

Prerequisites:
ruby
ruby-devel
ruby-mysql
rubygems
libmysqlclient
libmysqlclient-devel
libopenssl-devel
zlib-devel

Installation:
sudo gem install mysql
sudo gem install table_syncer

Settings:
cd /usr/lib64/ruby/gems/1.8/gems/table_syncer-0.3.1/lib
cp table_syncer.rb table_syncer.rb.orig
vi table_syncer.rb

Add and change these lines:
local_source_db = {:host => '127.0.0.1', :user => 'user', :password => 'password', :db => 'SourceDatabase'}
local_test_db = {:host => '127.0.0.1', :user => 'user', :password => 'password', :db => 'test'}

Executing
table_syncer --from=local_source_db --to=local_test_db --tables=account

Reference:
http://code.google.com/p/ruby-roger-useful-functions/wiki/TableSyncer
http://www.freelinuxtutorials.com/quick-tips-and-tricks/sync-mysql-tables-via-ruby-gem-tablesyncer/
http://forums.mysql.com/read.php?116,178217,198518#msg-198518

SCP & SSH

At local machine:
ssh-keygen -t rsa
cd ~/.ssh
cp id_rsa.pub authorized_keys
scp -p ~/.ssh/authorized_keys username@remoteMachine:.ssh/

Note that before executing scp you need to make sure there is ~/.ssh at remote machine also and create it if neccecery with
mkdir ~/.ssh

At remote machine:
cd
ls -ld . .ssh .ssh/authorized_keys
drwxr-xr-x 36 username username 4096 Jul 25 02:24 .
drwxr-xr-x 2 username username 512 Apr 10 02:30 .ssh
-rw-r--r-- 1 username username 1674 Apr 10 02:29 .ssh/authorized_keys

cd
chmod go-w . .ssh .ssh/authorized_keys

At local machine:
scp -p file username@remoteMachine:path/to/file

Reference:
http://kimmo.suominen.com/docs/ssh/

Mounting remote windows station

1) Using mount command:
mount -t cifs //192.168.0.4/Movies ~/Desktop/movies/

2) Using /etc/fstab file:
//192.168.0.4/Movies /media/remote/movies cifs file_mode=0777,dir_mode=0777,password=******** 0 0

Mounting iso file image:
mkdir /media/iso
mount -o loop -t iso9660 ~/file.iso /media/iso