Archive for the ‘Linux’ Category

Browsing the Internet with SSH tunneling

Tuesday, March 16th, 2010

On your server:
1. Just create an SSH account.

On your client (Linux/Mac):
1. Open a terminal and key in the following,
#ssh -fND 8080 username@remoteserver.net

2. Open Firefox and go to Preferences -> Advanced -> Network -> Proxy Settings and choose “Manual proxy configuration.”

3. Put “127.0.0.1″ for the SOCKS host field and “8080″ on the corresponding port field.

4. You can now start browsing.

Optional:

5. If you want to use the DNS server of the SSH server, open Firefox and key in “about:config” at the address bar.

6. Look for “network.proxy.socks_remote_dns.” Double-click it to change the value from “false” to “true”.

7. You can now start browsing!

  • Share/Bookmark

Installing and Running RubyOnRails on Ubuntu

Thursday, December 10th, 2009

sudo apt-get install ruby-full build-essential

or

sudo aptitude install ruby build-essential libopenssl-ruby ruby1.8-dev

sudo apt-get install rubygems

echo “export PATH=/var/lib/gems/1.8/bin:$PATH” >> ~/.bashrc

sudo gem update –system

INSTALLING Rails

sudo gem install rails

or

apt-get install rails (installing rails with gem is preferred)

sudo aptitude install libfcgi-dev

RUNNING RubyOnRails

rails /home/myuser/www/mynewapp -d mysql (-D if you installed rails with apt)

$cd /home/myuser/www/mynewapp
$ruby script/server

  • Share/Bookmark

Hardening TPC/IP in linux

Friday, November 20th, 2009

Execute the following:

sysctl -w net.ipv4.icmp_echo_ignore_broadcasts=1
sysctl -w net.ipv4.conf.all.accept_redirects=0
sysctl -w net.ipv6.conf.all.accept_redirects=0
sysctl -w net.ipv4.conf.all.send_redirects=0
sysctl -w net.ipv6.conf.all.send_redirects=0
sysctl -w net.ipv4.conf.all.accept_source_route=0
sysctl -w net.ipv4.conf.all.forwarding=0
sysctl -w net.ipv4.conf.all.rp_filter=1
sysctl -w net.ipv4.tcp_max_syn_backlog=1280
sysctl -w net.ipv4.tcp_syncookies=1
sysctl -w net.ipv4.conf.all.log_martians=1
sysctl -w net.ipv4.conf.all.mc_forwarding=0

To make it permanent, put the same line above minus the “sysctl -w ” command  in /etc/sysctl.conf

net.ipv4.icmp_echo_ignore_broadcasts=1
net.ipv4.conf.all.accept_source_route=0
net.ipv4.conf.all.mc_forwarding=0
net.ipv4.conf.all.rp_filter=1
net.ipv4.tcp_max_syn_backlog=1280
net.ipv4.tcp_syncookies=1
net.ipv4.conf.all.accept_redirects=0
net.ipv6.conf.all.accept_redirects=0
net.ipv4.conf.all.send_redirects=0

  • Share/Bookmark

Useful commands for displaying Network Services/Connections

Friday, November 20th, 2009

#netstat -an|awk ‘/tcp/ {print $6}’|sort| uniq -c

#netstat -anp

#lsof|grep LISTEN

  • Share/Bookmark

LToT+eLDI, a perfect combination

Tuesday, April 7th, 2009

Last year, I was fortunate enough to have participated in two international workshops. One was entitled,” eLDI – eLearning
Development and Implementation,” sponsored by the Federal Ministry for Economic Cooperation and Development (BMZ) on behalf of the Government of the Federal Republic of Germany, implemented and supported by common sense through Inwent. The other was, “IOSN-INWENT LINUX TRAINING OF TRAINERS (LToT),” presented by the ASEAN+3 Node of the International Open Source Network and Inwent Capacity Building International, Germany in cooperation with the Information Technology Center of the National University of Laos.

LToT participants
LToT participants

The eLDI workshop started from May 24, 2008 until February 6, 2009 with a total of 300 hours,  which includes 100 hours face to face and 200 hours online. The program consists of the following basic modules: Instructional Design, Content Development, Interactivitym eLearning Technology, eLearning Management, Tutoring and Support of Virtual Learning Communities. Both face to face workshops were held in the UPOU campus, in Laguna, Philippines.

eldi
eLDI participants

The LtoT workshop was held at the Information Techonology Center of the National University of Laos in Vientiane Capital, Lao PDR from the 8th to the 19th of September 2008. The workshop was for preapringparticipants for the Linux Professional Institute Certification Level 1 (LPIC-1).  The first week covered topics on LPI 101 which are the following: Hardware and Architecture; Linux Installation and Package Management; GNU and Unix Commands; Devices; Linux Filesystems; Filesystem Hierarchy Standard; and The X Window System. The second week covered topics on LPI 102 which are the following: Kernel; Boot, Initialization, Shutdown and Runlevels; Printing; Documentation; Shells, Scripting, Programming and Compiling; Administrative Tasks; Networking Fundamentals; Networking Services;  and Security.

With the knowledge and skills I have gained from both seminars, I was able to incorporate LPI topics with my courses in a blended learning approach. Recently, I also conducted a workshop on distance learningand will hold another one this April 2009 followed by another on LPI and open source solutions.  Since I got certified with LPIC-1, there
has  been a steady demand from our students and faculty for me to hold seminars on Linux and FOSS.

Now, I’m busier and happier than ever!

  • Share/Bookmark

moodle upgrade – database needs to be stored in utf-8

Tuesday, March 3rd, 2009

While I was upgrading moodle, I got this message:

It is required that you store all your data in Unicode format (UTF-8). New installations must be performed into databases that have their default character set as Unicode. If you are upgrading, you should perform the UTF-8 migration process (see the Admin page).

After googling around, I was able to get this solution:

1. Create a dump of your old database.

> mysqldump -uUSER -p OLD_DATABASE > OLD_DATABASE.sql

2. Create a new database. This is where you will transfer the old one.

mysql> create database NEW_DATABASE default charset=utf8;

mysql> grant all privileges on NEW_DATASE to ‘USER’@'localhost’;

3. Load your old database to the new one.

>mysql -uUSER -p NEW_DATABASE < OLD_DATABASE.sql

  • Share/Bookmark

grep on windows?

Tuesday, February 17th, 2009

I was just fiddling on the Windows command prompt and much to my surprise that I can use “find” like how I use “grep” on Linux. For example, you want to filter lines that have the word LISTEN, just enter the command(s) below:

> netstat -an|find “LISTEN”

  • Share/Bookmark

Automatically deny hosts from SSH brute force attacks

Friday, August 15th, 2008

1. Download denyhosts from:

http://denyhosts.sourceforge.net/

2. Extract file and follow README.txt

  • Share/Bookmark

Mini GnuPG (gpg) howto

Friday, August 15th, 2008

Mini GnuPG (gpg) howto

A. Creating your own gpg key.
1. Download and install gpg from http://www.gnupg.org

2. Generate gpg key
***BEGIN shell***
# gpg –gen-key
gpg (GnuPG) 1.4.7; Copyright (C) 2006 Free Software Foundation, Inc.
This program comes with ABSOLUTELY NO WARRANTY.
This is free software, and you are welcome to redistribute it
under certain conditions. See the file COPYING for details.

Please select what kind of key you want:
(1) DSA and Elgamal (default)
(2) DSA (sign only)
(5) RSA (sign only)
Your selection?1
DSA keypair will have 1024 bits.
ELG-E keys may be between 1024 and 4096 bits long.
What keysize do you want? (2048) 1024
Requested keysize is 1024 bits
Please specify how long the key should be valid.
0 = key does not expire
<n> = key expires in n days
<n>w = key expires in n weeks
<n>m = key expires in n months
<n>y = key expires in n years
Key is valid for? (0)
Key does not expire at all
Is this correct? (y/N) y

You need a user ID to identify your key; the software constructs the user ID
from the Real Name, Comment and Email Address in this form:
“Heinrich Heine (Der Dichter) <heinrichh@duesseldorf.de>”

Real name: Test User
Email address: testuser@foo.com
Comment: test user only
You selected this USER-ID:
“Test User (test user only) <testuser@foo.com>”

Change (N)ame, (C)omment, (E)mail or (O)kay/(Q)uit? O
You need a Passphrase to protect your secret key.

We need to generate a lot of random bytes. It is a good idea to perform
some other action (type on the keyboard, move the mouse, utilize the
disks) during the prime generation; this gives the random number
generator a better chance to gain enough entropy.
+++++++++++++++++++++++++.++++++++++++++++++++.

gpg: key 3C32C24C marked as ultimately trusted
public and secret key created and signed.

gpg: checking the trustdb
gpg: 3 marginal(s) needed, 1 complete(s) needed, PGP trust model
gpg: depth: 0 valid: 2 signed: 0 trust: 0-, 0q, 0n, 0m, 0f, 2u
gpg: next trustdb check due at 2012-03-27
pub 1024D/3C32C24C 2007-12-18
Key fingerprint = 3D63 CBA7 07CB 9646 E191 EBBB 3801 3C09 3C32 C24C
uid Test User (test user only) <testuser@foo.com>
sub 1024g/FDAFFDE3 2007-12-18

***END shell***

3. Check your new key
***BEGIN shell***
# gpg –list-keys “test user”
pub 1024D/3C32C24C 2007-12-18
uid Test User (test user only) <testuser@foo.com>
sub 1024g/FDAFFDE3 2007-12-18
***END shell***
Note: Your key ID is 3C32C24C

4. Send your key to a public key server
#gpg –keyserver <keyserver> –send-keys <key ID>

B. Signing keys to affirm that the sender is valid.

1. Trust sender key ID if you can verify the source. Ex. Face-to-face comfirmation, phone, video, gut feel :) , and other means you can think of.

2. Receive keys from other users by downloading from a trusted key server
#gpg –keyserver <keyserver> –recv-keys <key id>
#gpg –keyserver wwwkeys.pgp.net –recv-key B6CFD174

3. Sign the sender’s key ID
# gpg –sign-key <key ID>

4. Once you have signed the key, you can send it back to the key server
# gpg –keyserver <keyserver> –send-keys B6CFD174

5. After sending the sender’s key, other people can now download it along with your signature

C. Sending encrypted messages
1. To encrypt a file into an *.gpg binary file
# gpg –encrypt <filename>

2. To encrypt a file into an *.asc ASCII-armored file
# gpg –armor –encrypt <file>

D. Decrypting received messages
# gpg <filename>

E. Generating ASCII-armored versions of your key ID.
1. Some servers or people prefer the ASCII-armored version of your public key. Just enter the following line:
# gpg -a –export <public key ID> > your_public_key.asc

  • Share/Bookmark

LVM Mini Howto

Friday, August 15th, 2008

LVM Mini Howto

(1) Create LVM partitions
*** BEGIN shell ***
#fdisk /dev/sdb
Command (m for help): p

Disk /dev/sdb (Sun disk label): 255 heads, 63 sectors, 2202 cylinders
Units = cylinders of 16065 * 512 bytes

Device Flag Start End Blocks Id System
/dev/sdb1 0 2202 17687565 83 Linux native
/dev/sdb3 0 2202 17687565 5 Whole disk

Command (m for help): t
Partition number (1-8): 1
Hex code (type L to list codes): 8e
Command (m for help): w
*** END shell ***

(2) Repeat (1) for additional partitions

(3) If pvcreate is missing (in Debian), install lvm2
#apt-get install lvm2

(4) Create physical volume
# pvcreate /dev/sdb1

(5) Repeat (4) for additional volumes

(6) Create and name the volume group. Ex. volume group name “backup.”
#vgcreate backup /dev/sdb1 /dev/sdc1 /dev/sdd1

(7) Create and name the logical volume group. E. lvg name “backup-lvm”
# lvcreate -n backup-lvm –size 84.68g backup

(8) Format LVM with ext3
# mkfs.ext3 /dev/backup/backup-lvm

(9) Mount to any partition you want

  • Share/Bookmark