Sep 082009
 
This Expect script takes as it’s argument, the IP Address of an IOS device that is using AAA Authentication (Username/Password), and returns the OSPF Neighbors of the device.
Usage: ospf_neighbors_script ip address
The script also creates a file with the OSPF Neighbors in the directory it’s run from. The format is “ip address-ospf_neighbors”,
{quickdown:47}
kshort@LinuxStudent:~$ ospf_neighbors_script 10.255.0.26
Username? kshort
Password?
Trying 192.168.0.26…
Connected to 192.168.0.26.
Escape character is ‘^]’.

User Access Verification

Username: kshort
Password:

Test-Router#terminal length 0
Test-Router#sho ip ospf nei

Neighbor ID     Pri   State           Dead Time   Address         Interface
192.168.1.1       0   FULL/  -        00:00:38    192.168.0.85     Serial1/0.2
192.168.2.1       0   FULL/  -        00:00:38    192.168.0.25     Serial1/0.1
192.168.3.1       1   FULL/BDR        00:00:39    192.168.2.70     GigabitEthernet0/1
192.168.4.1       1   FULL/BDR        00:00:38    192.168.2.66     GigabitEthernet0/0
Test-Router#

Sep 162008
 

The other day I had to come up with a way to transfer a Solaris Express nv97 DVD 3G image to remote locations while not using the network. The reason for this is, I needed to perform a LiveUpgrade on over 700 boxes and each being at a different locations. So I said to myself I guess I can put this image on a custom LiveDVD… But then I said to myself, which Linux LiveCD/DVD distro will I use???? It has to be small enough so that I can fit the Solaris Express nv97 image as well as the LiveCD Image.

Continue reading “HowTo Remaster a LiveCD or LiveDVD using SLAX” »

Aug 192008
 

This script will find a MAC address on a Cisco IOS based switch.

Here’s what you’ll see when the switch is successful and unsuccessful finding the MAC address.

Notice it prompts you for your username and password. This script is integrated with the Expect Telnet script on this site.

 

kshort@LinuxStudent:~$ ./findMACaddress_final 10.10.12.1
Enter the MAC Address? 0013.72fb.3050
Username? kshort
Password?

——————-Here Are the The Results of Your Search——————

vlan   mac address     type    learn     age              ports
——+—————-+——–+—–+———-+————————–
Supervisor:
*   95  0013.72fb.3050   dynamic  Yes         65   Gi1/3

Continue reading “Expect Script to find MAC Address on Cisco IOS Devices” »

May 182008
 

There are a bunch of great regular expressions HowTo’s out there….. Now you may be asking why am I creating another??? Well quite simple, I am creating this one because this is not really just a regular expression howto but more a regular expression HowTo with its everyday uses with linux/unix commands.  So it will not cover perl/python/ruby/…etc programming languages regular expressions (That will be for another tutorial :) )

To start this off I will give you a basic introduction to regular expressions using the output
of "ls" and piping it "grep" using the -oE options (The o stands for Exact match and the E stands for Extended Regular Expressions). Using "(BRE and ERE) Basic Regular Expressions and Posix Extended Regular Expressions"…

THIS IS NOT A TUTORIAL BUT A HOWTO!! So this means more examples and less explaining..

 

Anchors

What it means 

Example 

^

Start of string

ls |grep -oE "^Cw+.jpg"
Chunka.jpg
Chunka1.jpg

$ 

End of string 

ls |grep -oE "w+(.jpg$)"
Chunka.jpg
Chunka1.jpg
DSCF0732.jpg

b 

Word boundary 

ls |grep -oE "bChunkab.jpg"
Chunka.jpg

< 

Start of word 

ls |grep -oE "<Chw+.jpg"
Chunka.jpg
Chunka1.jpg

> 

End of word 

ls Scripts/Python/ |grep -oE "w+>.py"
xen_mac_generate.py 

 Character Classes 

What it means 

Example 

w 

Word 

ls | grep -oE "w"
C
C

Non word 

ls |grep -oE "W"
.
.

Quantifiers 

what it means 

example 

* 

zero or more times

ls | grep -oE "w*.jpg"
Chunka.jpg
Chunka1.jpg
DSCF0732.jpg

+ 

one or more times 

ls | grep -oE "w+"
Chunka
Chunka1
DSCF0732

? 

matches either once or zero times

ls | grep -oE "Chunka1?.jpg"
Chunka.jpg
Chunka1.jpg

{2} 

Exactly 2 times

ls | grep -oE "(^C{2}hw+.jpg)"
CChunka.jpg

{1,}

1 or more times

ls | grep -oE "(^C{1,}hw+.jpg)"
CChunka.jpg
CCChunka.jpg
Chunka.jpg
Chunka1.jpg
Chunka11.jpg

{1,2} 

1 through 2 times

ls | grep -oE "(^C{1,2}hw+.jpg)"
CChunka.jpg
Chunka.jpg
Chunka1.jpg
Chunka11.jpg

 

Special Characters 

What it means 

Example 

n 

New line 

 

r 

Carriage return 

 

t

Tab 

 

v

Vertical tab 

 

f

Form feed 

 

 

  

May 172008
 

In the the first part of this HowTo,  I gave you the bare minimum to get Screen working
and how to use it on a day to day basis…. This time around I will show you some
of the advanced features of screen that may make your life easier in the terminal..

Before continuing this HowTo please read Part 1 if you do not have previous experience with screen.
So lets start this HowTo with some more Screen Commands…

 

Continue reading “Screen HowTo Part 2” »

May 112008
 

I’ve been using screen for the past 3 years and for the first time I’ve decided to seek out more functionality out of it.  So last week I spent about 2 hours looking up some of the different functionality that I can use in the day to day. Let me tell you I found a bunch of goodies that I use now religiously (For a week now ;) ).

So for those of you who do not know what a screen session is… (STRAIGHT FROM THE MAN PAGES) Screen is a full-screen window manager that multiplexes a physical terminal between several processes (typically interactive shells).  Essentially you can have 30 terminal sessions inside one terminal and much more…..

 

Continue reading “Screen HowTo Part 1” »

Feb 102008
 

In this tutorial we will show you how to authenticate to a already configured ldap server

  1. This file "/etc/ldap.conf" is the 1st file that has to be modified as this is the file that tells the system which ldap server to authenticate too.

    host yourdomain.com
    base dc=yourdomain,dc=com
    uri ldap://yourdomain.com/
    ldap_version 3
    rootbinddn cn=Manager,dc=yourdomain,dc=com
    scope sub
    timelimit 5
    bind_timelimit 5
    nss_reconnect_tries 2
    pam_login_attribute uid
    pam_member_attribute gid
    pam_password md5
    pam_password exop
    nss_base_passwd ou=People,dc=yourdomain,dc=com
    nss_base_shadow ou=People,dc=yourdomain,dc=com
  2. Now we have to add the passwd in this file "/etc/ldap.secret" so that we can authenticate to the ldap server
    password
  3. Now we have to modify this file "/etc/nsswitch.conf"

    passwd: files ldap
    group: files ldap
    hosts: dns ldap
    services: ldap [NOTFOUND=return] files
    networks: ldap [NOTFOUND=return] files
    protocols: ldap [NOTFOUND=return] files
    rpc: ldap [NOTFOUND=return] files
    ethers: ldap [NOTFOUND=return] files
    netmasks: files
    bootparams: files
    publickey: files
    automount: files
    sendmailvars: files
    netgroup: ldap [NOTFOUND=return] files
  4. Now it is time to modify the files in /etc/pam.d/ directory.
    First file to be modified is "/etc/pam.d/login"

    auth sufficient pam_ldap.so
    account sufficient pam_ldap.so
    password sufficient pam_ldap.so
    session sufficient pam_ldap.so

    auth requisite pam_securetty.so
    auth requisite pam_nologin.so
    auth sufficient pam_ldap.so
    auth required pam_unix.so use_first_pass
    auth required pam_tally.so onerr=succeed file=/var/log/faillog
    account required pam_access.so
    account required pam_time.so
    account required pam_unix.so
    account sufficient pam_ldap.so
    password sufficient pam_ldap.so
    session required pam_mkhomedir.so skel=/etc/skel/ umask=0022
    session required pam_unix.so
    session required pam_env.so
    session required pam_motd.so
    session required pam_limits.so
    session optional pam_mail.so dir=/var/spool/mail standard
    session sufficient pam_ldap.so
    session optional pam_lastlog.so
  5. Now we modify "/etc/pam.d/shadow"
    auth sufficient pam_ldap.so
    account sufficient pam_ldap.so
    password sufficient pam_ldap.so
    session sufficient pam_ldap.so

    auth sufficient pam_rootok.so
    auth required pam_unix.so
    auth sufficient pam_ldap.so use_first_pass
    account required pam_unix.so
    account sufficient pam_ldap.so
    session required pam_unix.so
    session sufficient pam_ldap.so
    password sufficient pam_ldap.so
    password required pam_permit.so
  6. Now we modify "/etc/pam.d/passwd"
    password sufficient pam_ldap.so

    password sufficient pam_ldap.so
    password required pam_unix.so shadow nullok
  7. Now we modify "/etc/pam.d/su"
    auth sufficient pam_ldap.so
    account sufficient pam_ldap.so
    session sufficient pam_ldap.so

    auth sufficient pam_ldap.so
    auth sufficient pam_rootok.so
    auth required pam_unix.so use_first_pass
    account sufficient pam_ldap.so
    account required pam_unix.so
    session sufficient pam_ldap.so
    session required pam_unix.so
  8. Now we modify "/etc/pam.d/sudo"
    auth sufficient pam_ldap.so

    auth sufficient pam_ldap.so
    auth required pam_unix.so use_first_pass
    auth required pam_nologin.so
  9. In this file "/etc/pam.d/sshd" you have to add 3 entries, one for auth, one for account, and one for session.
    auth sufficient pam_ldap.so
    account sufficient pam_ldap.so
    password required pam_ldap.so

    auth required pam_nologin.so
    auth sufficient pam_ldap.so
    auth required pam_env.so
    auth required pam_unix.so use_first_pass
    account sufficient pam_ldap.so
    account required pam_unix.so
    account required pam_time.so
    password required pam_ldap.so
    password required pam_unix.so
    session required pam_mkhomedir.so skel=/etc/skel/ umask=0022
    session required pam_unix_session.so
    session sufficient pam_ldap.so
    session required pam_limits.so

LVM2 How To

 Uncategorized  No Responses »
Feb 102008
 

Do you have the need for speed???… OK OK enough with the comments :P …Before reading this tutorial you should understand a little how LVM works

How to create a physical volume, volume group, and logical volume.

    • First thing we have to do is initialize the disk..

    • Figure out which disk and partitions you have that are being used df -h.
    • Now we need to run fdisk -l and see all the partitions, including the ones that we have that are not mounted up
    • Now that we know which disks and partitions that you can not destroy, we can start our process of creating lvm volumes.
    • Here we will start with the initialization of the lvm volumes.(Either we use the entire disk or a partition)Here we will show you on partitions.

    • Lets initialize the first partition..
      pvcreate /dev/sda1.
    • Now lets initialize the second partition..
      pvcreate /dev/sdb1.
    • To display info on the physical volume, just run this
      pvdisplay.
    • Now that both partitions have been initialized, it is time to create the volume group and activate it.

    • vgcreate linuxdynasty /dev/sda1 /dev/sdb1
    • vgchange -a y linuxdynasty
    • To display info on the volume group, just run this
      vgdisplay.
    • We have reached the final step (for the LVM part of it).

    • Now we create the logical volume.
      lvcreate -L10G -nHomeLV linuxdynasty
    • To display info on the logical volume, just run this
      lvdisplay.
    • Final steps, we need to make a file system on that volume and mount it.

    • First, we create the file system
      mkfs.ext3 /dev/linuxdynasty/HomeLV
    • Second, we mount the file system
      mount -t ext3 /dev/linuxdynasty/HomeLV /home
Feb 102008
 

Ever wanted to know how you can ssh into your work desktop/server? Well do not worry any longer…..

    • All you need to do is create a reverse tunnel from your Work Desktop/Server to your home server.

    • ssh -nNT -R 5000:local_server:22 username@remote_server
    • Now from the remote_server run this
      ssh -p5000 localhost…. now we are in our work desktop/server.
    • Lets brake this down a bit..

    • The -n option Redirects stdin from /dev/null. This must be used when ssh is run in the background.
    • The -N option does not execute a remote command. This is useful for just forwarding ports.
    • The -T option disables pseudo-tty allocation.
    • The -R option does tha job of setting up the reverse tunnel.
    • Port 5000 is the port that will be listening on the remote_server (this can be any random port over 1024, if you want to run this as a non-root user).
    • local_server is the desktop/server that you are creating the connection from.
    • Port 22 is the port that you are making the ssh connection to.
    • user_name@remote_server is where you are making the ssh connection to for the reverse tunnel.
    • We need to make sure we keep this connection open.

    • In /etc/ssh/sshd_config we need to make sure this is set TCPKeepAlive yes.
Feb 102008
 

Have you forgotten the root password on your box and said @#$%%^. Well do not fear, Linux Dynasty is here to save the day.

    • Booting into single user mode from GRUB.

    • First, reboot your system.
    • Second, When GRUB comes up type e (got to be quick).
    • Third, now select entry that begins with kernel and hit enter.
    • Fourth, at the end of the kernel entry type either s or single, now hit enter.
    • Fifth, type b, the box will boot up and now you can type in the cmd prompt passwd root. This will reset the password to whatever you like.
    • If this does not bring you to a root prompt, then try this.
    • Then try appending single init=/bin/bash

    Be happy, now you have root access again. or maybe for the first time… ;)

    • Booting into single-user mode from LILO

    • First, reboot your system.
    • Second, When LILO comes up, type in linux s. Hit enter.
    • Box will boot into single user mode, which brings you to a root prompt. If this does not happen to you, and ask you for the root password, you will have to do the following.
    • Try this linux init=/bin/bash

Warning: fopen(/home/dynasty/linuxdynasty.org/wp-content/plugins/wp-google-plus-one/lib/standard.txt) [function.fopen]: failed to open stream: No such file or directory in /home/dynasty/linuxdynasty.org/wp-content/plugins/wp-google-plus-one/plusone.php on line 104

Warning: fread(): supplied argument is not a valid stream resource in /home/dynasty/linuxdynasty.org/wp-content/plugins/wp-google-plus-one/plusone.php on line 105

Warning: fclose(): supplied argument is not a valid stream resource in /home/dynasty/linuxdynasty.org/wp-content/plugins/wp-google-plus-one/plusone.php on line 106
.