Subscribe to RSS Feed

Linux

SSH Tunnel with Putty and Squid

The purpose of this guide is to provide an easy to follow set of instructions that should allow you to create an SSH tunnel in around 10 minutes.
Step 1: Getting started
What you will need:

  • Remote server running SSH (Debian server is used in this guide)
  • Putty
  • Squid

Install squid:
apt-get install squid
Step 2: Configure putty

  • Start putty
  • From left hand tree menu select Click SSH (under the Connection menu item) to expand the tree items, then click on Tunnels
  • In Source port enter 3128 (default Squid port), select Dynamic and click on the Add button
  • In the left hand menu go to Session
  • Put the hostname of your server, select SSH (if not already selected), then under Saved Sessions type tunnel (or any name you want to call the saved session) and click save.  This will enable you, in the future to click on “tunnel”, click Load, then Open.
  • Click Open.  You cannot SSH tunnel without an open connection, it will ask you for your username and password.

Step 3: Configure Firefox

  • Click Tools, then select Options…
  • Select the Advanced option then then Network tab.
  • Click on Settings
  • Select Manual proxy configuration, then under SOCKS Host type localhost and in Port enter 3128 (In Vista SP1 you might have to use 127.0.0.1 instead of localhost for the SOCKS Host)

Congratulations, you should now have a fully functioning SSH Tunnel, you can test this by going to Whats My IP

Continue Reading »
No Comments
PXE install Ubuntu via Windows

The purpose of this article is to explain, step by step, how to install Ubuntu (Ubuntu is my distro of choice, but the steps should work equally well for other distros) using a Windows 2000/XP client.
Introduction
PXE (Preboot Execution Environment) is not something new, but not often used by home users, as installing an operating system by CD/DVD or USB storage is generally easier, if however you have none of those, your only real option is to network boot (Assuming you have a network port and access to the internet).
The Problem
I bought my sister a cheap laptop from ebay for her birthday, shes not a power user so i picked up a Dell L400 for £100, its only got a 700MHz processor in it and 256MB of RAM, but for general web browsing it will suit her, however, its a sub notebook, and so doesnt come with a cd drive, nor can it boot from a usb cd drive (took me about half an hour to find that out), so in the end my only real option was to netboot it.
Step 1: Prerequisites

  • Get a copy of the free TFTP server by Philippe Jounin.
  • Get the ubuntu installer files. Download the folder netboot (ignore any symlinks, they may give you errors during the download).
  • That’s all we need to boot our Ubuntu installer over the network. Let’s setup the TFTP server.
    Step 2: Setting up a TFTP Server.

  • Create a directory, preferably on your C Drive. We’ll name it tftp for now.
  • copy the tftpd32.exe to c:tftp
  • Start the server by clicking on the exe
  • switch to the tab “DHCP Server” and fill in your network setup. Note that the PC you want to boot must be in the same Subnet. Enter pxelinux.0 as the boot file. The Screenshot below shows my setup.
  • Now we need to copy the Ubuntu netboot installer over to our tftp root directory:

  • copy the folder ubuntu-installer to c:tftp
  • copy the folder pxelinux.cfg from ubuntu-installer/i386/ to c:tftp
  • copy the file pxelinux.0 from ubuntu-installer/i386/ to c:tftp
  • Step 3: Booting Ubuntu
    To boot from tftp you may need to activate booting from the network interface in the BIOS. This may be done in the boot sequence settings or directly in the onboard ethernet device settings. After that, restart, lean back and watch the activities in the log viewer tab of the tftpd.
    Note: Ubuntu will let you choose a mirror and download all the files you need. The whole procedure will work with any other debian flavour almost identically. There is a nice how to on doing a PXE install via Linux instead of windows at the CCC Wiki.

    Note: this is a slightly modified version of the post from Retro at http://hugi.to/blog/archive/2006/12/23/ubuntu-pxe-install-via-windows

    Continue Reading »
    No Comments

    Setting up DHCP

    April 6, 2008 by admin

    Check System Compatibility

    Type:
    ifconfig -a

    you should see something like:
    eth0 Link encap:Ethernet HWaddr 00:09:5B:04:5E:78
    inet addr:82.36.57.31 Bcast:255.255.255.255 Mask:255.255.248.0
    inet6 addr: fe80::209:5bff:fe04:5e78/64 Scope:Link
    UP BROADCAST NOTRAILERS RUNNING MULTICAST MTU:1500 Metric:1
    RX packets:5561334 errors:0 dropped:0 overruns:0 frame:0
    TX packets:214278 errors:0 dropped:0 overruns:0 carrier:0
    collisions:0 txqueuelen:100
    RX bytes:462931787 (441.4 Mb) TX bytes:28300458 (26.9 Mb)
    Interrupt:12 Base address:0xa000

    If it doesnt say MULTICAST you should reconfigure your kernal and add multicast support.

    Currently the latest version is 2.0 (suggested for most users) but 3.0 is in beta testing. You can get them from ftp://ftp.isc.org/isc/dhcp/

    After you download unpack it, then cd into the distribution directory:
    ./configure
    make
    make install

    Server Configuration:

    Next step is to add route for 255.255.255.255. Quoted from DHCPd README:

    “In order for dhcpd to work correctly with picky DHCP clients (e.g., Windows 95), it must be able to send packets with an IP destination address of 255.255.255.255. Unfortunately, Linux insists on changing 255.255.255.255 into the local subnet broadcast address (here, that’s 192.5.5.223). This results in a DHCP protocol violation, and while many DHCP clients don’t notice the problem, some (e.g., all Microsoft DHCP clients) do. Clients that have this problem will appear not to see DHCPOFFER messages from the server.”

    Type: route add -host 255.255.255.255 dev eth0
    (or eth1 depending on the interface you are configuring)

    DHCPd.conf Configuration

    create or edit /etc/dhcpd.conf

    The following is a sample which randomly assigns IP addresses.

    #sample /etc/dhcpd.conf
    ddns-update-style ad-hoc;
    option subnet-mask 255.255.255.000;
    option routers 192.168.60.1;
    option domain-name-servers 62.31.144.39, 195.188.53.175, 195.188.53.175;
    default-lease-time 3600;
    max-lease-time 7200;

    subnet 192.168.60.0 netmask 255.255.255.000
    { range 192.168.60.2 192.168.60.244;
    }

    This will give a client an IP address in the range 192.168.60.2-192.168.60.244. It will lease an IP address for 3600 seconds if the client doesn’t ask for specific time frame. Otherwise the maximum (allowed) lease will be 7200 seconds. It sets the default DNS servers as 62.31.144.39, 195.188.53.175 and 195.188.53.175.

    You can also assign specific IP addresses based on clients ethernet address e.g.

    host myPC {
    hardware ethernet 00:25:83:17:a3:6e;
    fixed-address 192.168.60.246;
    }

    This will assign IP address 192.168.60.246 to a client with ethernet address 00:25:83:17:a3:6e

    You can mix and match, giving certain clients “static” IP addresses such as servers and others being given dynamic IPs such as mobile users with laptops.

    Starting the server

    Generally DHCP installation doesn’t create a dhcpd.leases files, this file is needed by DHCPd to store information about current leases. To create dhcpd.leases type:
    touch /var/state/dhcp/dhcpd.leases

    If you get a message saying that file exists simply ignore it and carry on.

    You can now invoke the DHCP server. Simply type (or include in the bootup scripts)

    /usr/sbin/dhcpd

    This will start dhcpd on eth0 device. To start it on another device just supply the device on the command line i.e.

    /usr/sbin/dhcpd eth1

    If you want dhcpd to start at boot-up include dhcpd in e.g.

    /etc/rc.d/rc.local

    Continue Reading »
    No Comments

    Screen

    April 6, 2008 by Kode

    Getting in
    start a new screen session: screen
    attach to a running session: screen -r
    attach multiple terminals to an attached, running session: screen -rx
    the “ultimate attach”: screen -dRR (Attaches to a screen session. If the session is attached elsewhere, detaches that other display. If no session exists, creates one. If multiple sessions exist, uses the first one.)
    Escape key
    All screen commands are prefixed by an escape key, by default Ctrl+a (sometimes written ^A). To send a literal Ctrl+a to the programs in screen, use Ctrl+a a.
    Getting out
    detach: Ctrl+a d
    exit screen: exit all of the programs in screen.
    force-exit screen: Ctrl+a C-\ (not recommended)
    Help
    See help: Ctrl+a ? (lists keybindings)
    Window Management
    create new window: Ctrl+a c
    change to last active window: Ctrl+a Ctrl+a
    change to window by number: Ctrl+a <number> (only for windows 0 to 9)
    change to window by number or name: Ctrl+a ‘ <number or title>
    change to next window in list: Ctrl+a n or Ctrl+a <space>
    change to previous window in list: Ctrl+a p
    see window list: Ctrl+a “
    close current window: Close all applications in the current window (including shell)
    kill current window: Ctrl+a k (not recommended)
    Split screen
    split display: Ctrl+a S
    jump to next display region: Ctrl+a tab
    remove current region: Ctrl+a X
    remove all regions but the current one: Ctrl+a Q
    Misc
    redraw window: Ctrl+a C-l
    enter copy mode: Ctrl+a [ (also used for viewing scrollback buffer)
    paste: Ctrl+a ]
    monitor window for activity: Ctrl+a M
    monitor window for silence: Ctrl+a _
    enter digraph: Ctrl+a Ctrl+v
    lock (password protect) display: Ctrl+a x
    enter screen command: Ctrl+a :

    Continue Reading »
    1 Comment

    Quick Commands

    April 6, 2008 by admin

    alias – this allows the user view the current aliases
    awk – this allows the user to search for a pattern within a file
    bdiff – compares two large files
    bfs – scans a large file
    cal – shows a calendar
    cat – concatenates and prints a file
    cc – c compiler
    cd – changes directories
    chgrb – changes a file groups ownership
    chmod – changes the permission on a file
    chown – changes the individual ownership of a file
    cmp – compairs two files
    comm – compares two files so as to determine which lines are common to both
    cp – copies file to another location
    cu – calls another unix sysytem
    date – returns the date and time
    df – shows all mounted drives on your machine
    diff – displays the diference between two files
    du – shows the disk usage in blocks for a directory
    echo – echoes the data to the screen or file
    ed – text editor
    env – lists the current environment variables
    ex – another text editor
    expr – evaluates a mathmatical formula
    find – finds a file
    f77 – fortran complier
    format – initializes a floppy disk
    grep – searches for a pattern within a file
    help – gives help
    kill – stops a running process
    ln – creates a link between two files
    lpr – copies the file to the line printer
    ls – lists the files in a directory
    mail – allows the user to send/receive mail
    mkdir – makes directory
    more – displays a data file to the screen
    mv – used to move or rename files
    nohup – allows a command to continue running even when you log out
    nroff – used to format text
    passwd – changes your password
    pkgadd – installs a new program onto your machine
    ps – Lists the current processes running
    pwd – displays the name of the working directory
    rm – removes files
    rmdir – removes directories
    set – lists all the variables in the current shell
    setenv – sets the environment variables
    sleep – causes a process to become inactive
    source – allows the user to execute a file and update any changed values in that file
    sort – sorts files
    spell – checks for spelling errors in a file
    split – divides a file
    stty – sets the terminal options
    tail – displays the end of a file
    tar – copies all specified files into one
    touch – creates an empty file or updates the time/date stamp on a file
    troff – outputs formatted output
    tset – sets the terminal type
    umask – specify a new creation mask
    uniq – compairs two files
    uucp – unix to unix execute
    vi – full screen editor
    vipw – opens the vi editor as well as password file for editing
    volcheck – checks to see if there is a floppy disk mounted to your machine
    wc – displays detail in the full size
    who – inf. on other people online
    write – send a message to another user
    ! – repeats commands

    Continue Reading »
    No Comments

    Install MySQL 4.1.3
    Download these RPMS to /usr from http://www.mysql.com

    MySQL-server-4.1.8-0.i386.rpm
    MySQL-devel-4.1.8-0.i386.rpm
    MySQL-client-4.1.8-0.i386.rpm
    MySQL-shared-4.1.8-0.i386.rpm

    Install them with: rpm -i MySQL*.rpm

    Source Files
    Download these files (or newer versions) to /usr/local/src
    (the packages will be located in /usr/local/lib when they are installed unless otherwise stated)
    zlib-1.2.1.tar.gz from http://www.gzip.org/zlib/
    libxml2-2.6.11.tar.gz from http://www.xmlsoft.org/
    php-5.0.3.tar.gz from http://www.php.net/downloads.php
    httpd-2.0.52.tar.gz from http://httpd.apache.org/
    http://www.openssl.org/source/openssl-0.9.7e.tar.gz
    http://puzzle.dl.sourceforge.net/sourceforge/libssh2/libssh2-0.4.tar.gz

    Decompress the files
    cd /usr/local/src
    tar xzf zlib-1.2.1.tar.gz
    tar xzf libxml2-2.6.11.tar.gz
    tar xzf httpd-2.0.52.tar.gz
    tar xzf php-5.0.3.tar.gz
    tar xzf openssl-0.9.7e.tar.gz
    tar xzf libssh2-0.4.tar.gz

    Compile zlib
    cd zlib-1.2.1/
    ./configure
    make
    make install
    cd ..

    Compile libxml2
    cd libxml2-2.6.11
    ./configure
    make
    make install
    cd ..

    Compile OpenSSL
    cd openssl-0.9.7e
    make
    make install
    cd ..

    Compile libssh2
    cd libssh2-0.4
    ./configure
    make
    cd ..

    Compile apache2 (installs to /usr/local/apache2)
    cd httpd-2.0.52
    ./configure –prefix=/usr/local/apache2 –enable-so –with-openssl=/usr/local/
    make
    make install
    cd ..

    to start / stop Apache execute:
    /usr/local/apache2/bin/apachectl start
    /usr/local/apache2/bin/apachectl stop

    Apache config directory:
    /usr/local/apache2/conf/

    htdocs directory:
    /usr/local/apache2/htdocs/

    Compile PHP5 (installs to /usr/local/php5)
    cd php-5.0.3
    ./configure –prefix=/usr/local/php5
    make
    make install
    cd ext
    /usr/local/php5/bin/pear download ssh2-0.4.1
    gzip -d < ssh2-0.4.1.tgz | tar -xvf -
    mv ssh2-0.4.1 ssh2
    rm package.xml
    cd ..
    ./buildconf –force

    ./configure –prefix=/usr/local/php5 \
    –with-apxs2=/usr/local/apache2/bin/apxs \
    –with-libxml-dir=/usr/local/lib –with-zlib \
    –with-zlib-dir=/usr/local/lib \
    –with-mysql=/usr –with-mysqli=/usr/bin/mysql_config \
    –with-gd –enable-soap –enable-sockets \
    –with-jpeg-dir=/usr –enable-exif \
    –enable-magic-quotes –with-tsrm-pthreads –with-openssl –with-ssh2

    make (if u get errors about files being truncated try “make clean” first)

    .. gave me lots of ‘multiple defined’ error for libmysql;
    these errors go away if you drop either –with-mysql or
    –with-mysqli;

    if you want to use both the old mysql and the new mysqli
    interface, load the Makefile into your editor and search
    for the line beginning with EXTRA_LIBS; it includes
    -lmysqlclient twice; remove the second instance

    make
    make install
    cd ..

    location of php.ini:
    /usr/local/lib/php.ini

    Edit httpd.conf
    the command make install of the PHP build automatically
    adds the following line to /usr/local/apache2/conf/httpd.conf:
    LoadModule php5_module modules/libphp5.so

    however, you have to add another line:

    AddType application/x-httpd-php .php

    Test it all

    restart Apache
    /usr/local/apache2/bin/apachectl start
    /usr/local/apache2/bin/apachectl stop

    create the file
    /usr/local/apache2/htdocs/test.php
    with this content

    load the page with your web browser
    http://localhost/test.php

    Start Apache automatically (Init-V)
    if Apache should start automatically when you start
    your system, you have to add a init Script; if you use
    SUSE, copy /etc/init.d/skeleton to /etc/init.d/apache2
    and adapt it according to your needs; the following lines
    summarize the most important parts

    #! /bin/sh
    # /etc/init.d/apache2

    case “$1″ in
    start)
    echo -n “Starting apache2″
    /usr/local/apache2/bin/apachectl start
    rc_status -v
    ;;
    stop)
    echo -n “Shutting down apache2″
    /usr/local/apache2/bin/apachectl stop
    rc_status -v
    ;;
    restart)
    $0 stop
    $0 start
    rc_status
    ;;
    *)
    echo “Usage: $0 {start|stop|restart}”
    exit 1
    ;;
    esac

    Continue Reading »
    No Comments