Posted by pymaunier on Tue 15 Aug 2006 at 09:34
This article will describe you how to install a complete solution to manage users that have access to your network devices and also how to automatically backup your network devices configurations with a cvs based storage in order to have diffs on it. You'll also be able to script commands you want to run on your routers/switches to have easier administration.
Introduction
This document is in constant evolution, do not hesitate to check it sometimes. If you see something that have to be added/corrected, feel free to contact me.
Follow this document step by step and it will work without problems, do not jump a section, read it carrefully.
Note : This document has been written for cisco devices only using IOS software. It should work with other network devices vendor (such as Juniper, Foundry...) but you should read vendor's documentation and rancid one to see how to configure it properly. It also works with Cisco using catos software but no catos commands are provided in this document.
Installation
Note : Don't do an apt-get install tac-plus, it's the cisco version which should not work with the configuration file of this manual. The shrubbery version is also more updated.This document has been written using tacacs+-F4.0.4.10.
# apt-get install libwrap0-dev gcc make libc6-devOnce you've got the tacacs+ archive, you have to uncompress it (in /usr/src for example).
# cp tacacs+-F4.0.4.10.tar.gz /usr/src # cd /usr/src # tar xvfz tacacs+-F4.0.4.10.tar.gz # cd tacacs+-F4.0.4.10 # ./configure # make installInstallation directories are the following :
#
# tacacs configuration file
# Pierre-Yves Maunier - 20060713
# /etc/tac_plus.conf
# set the key
key = cle_tacacs
accounting file = /var/log/tac_plus.acct
# users accounts
user = tifrere {
login = cleartext "normal"
enable = cleartext "enable"
name = "Pierre-Yves Maunier"
}
For the moment you have an user called "tifrere". His password to get connected on the device is "normal" and the password to get in priviliged mode is "enable".# tac_pwd Password to be encrypted: normal yrVMIa532Sy.2 # tac_pwd Password to be encrypted: enable Elwo6gXCbVulwSo we change tifrere's account like this :
user = tifrere {
login = des "yrVMIa532Sy.2"
enable = des "Elwo6gXCbVulw"
name = "Pierre-Yves Maunier"
}
For more security, we change the permissions of the configuration file :
# chmod 600 /etc/tac_plus.conf
Note : We will create a local user on the cisco device which be usable only if the tacacs server is unreachable. This user account will be disabled when the tacacs server is reachable.In this example, the local user account will be :
aaa new-model aaa authentication login telnet group tacacs+ local aaa authentication login console group tacacs+ local aaa authentication enable default group tacacs+ enable aaa authorization exec default if-authenticated none aaa accounting update newinfo aaa accounting exec default start-stop group tacacs+ ! enable secret local_secret ! username local_user secret local_password ! line con 0 login authentication console line vty 0 4 login authentication telnet line vty 5 15 ! tacacs-server host 192.168.10.64 tacacs-server key cle_tacacs
Note : 192.168.10.64 is the ip address of the tacacs+ server---------- Explainations ----------
Router(config)# aaa authentication login {default | list-name} method1
[method2...]
list-name is a char string used to give a name to the authentication list. The argument method allow to list the authentication methods that have to be used ('group tacacs+' and 'local' here). The first method will always be used and the second one will be used only if the first method return an error, not if the authentication fails : usefull when you want to have the local authentication only if the tacacs+ server is unreachable.Router(config)# aaa authentication enable default method1 [method2...]The same as above but for the privilege mode password, we look in the tacacs+ server and the local authentication is used only if the tacacs+ server is unreachable.
# tac_plus -C /etc/tac_plus.confNow the device should use the tacacs+ server for the authentication, we can use the users created in the tacacs+ configuration file.
# telnet switch Trying 192.168.10.111... Connected to switch. Escape character is '^]'. User Access Verification Username: tifrere Password: // password : normal switch>en Password: // password : enable switch#If you have any problem, use the command "debug aaa authentication" on the cisco to troubleshoot the tacacs server and verify what happens when you try to connect.
# tail -f /var/log/tac_plus.acct
# apt-get install expect cvsrancid user creation (this user will launch all rancid related process)
# adduser --home /home/rancid rancidOnce you've got the rancid archive, you have to uncompress it ... (in /usr/src for example)
# cp rancid-2.3.1.tar.gz /usr/src # cd /usr/src # tar xvfz rancid-2.3.1.tar.gz # cd rancid-2.3.1... and install it
Note : The following commands have to be typed as root. But once Rancid is installed, rancid user MUST be owner of his directory (chown -R rancid:rancid /home/rancid).
# ./configure -prefix=/home/rancid -localstatedir=/home/rancid/var/rancid # make installThe README file in rancid archive is very well written and contain detailled informations, I kindly advise you to read it.
LIST_OF_GROUPS="mouarf"---------- Explainations ----------
LIST_OF_GROUPS="Paris London Amsterdam"
user = rancid {
login = cleartext "rancid_login"
enable = cleartext "rancid_enable"
name = "Rancid User"
}
Note : You could (strongly recommanded) use DES encryption for the passwords with the command tac_pwd (see previous section).No we create rancid .cloginrc at the rancid root home directory (/home/rancid/.cloginrc).
# /home/rancid/.cloginrc
add user * {rancid}
add password * {rancid_login} {rancid_enable}
As this file contains clear text passwords (you can't crypt them) you have to protect it. (And make sure rancid is the owner)
# chmod 600 .cloginrc # chown rancid:rancid .cloginrc
Note : For more informations about clogin, a section at the end of this document describes it.For the next section, for more informations, please read the rancid documentation which is very well written.
# su - rancid $ /home/rancid/bin/rancid-cvsThis command create all necessary files and directories for every groups of the option LIST_OF_GROUPS et import them into CVS. This command MUST be launched every time a new group is added. Do not create directories or CVS repository manualy.
Note : If /home/rancid/var/ranvid/CVS/group_name is not created : check the permissions, rancid has to be owner of his entire directory.For each group, modify the file router.db
- delete /home/rancid/var/rancid/group_name
- relaunch rancid-cvs (as rancid user)
#hostname:os:status switch1.office:cisco:up router1.office:cisco:up
Note : Hostname MUST resolve ! Don't forget to add them in /etc/hostsLaunch rancid-run (as rancid user !! I will never say it too much)
$ /home/rancid/bin/rancid-runrancid-run will connect automatically to switch1 and router1, will retrieve the configuration and will store it in /home/rancid/var/rancid/mouarf/configs/.
# apt-get install cvswebModify the cvsweb configuration file to create the group "mouarf" : File : /etc/cvsweb.conf
@CVSrepositories = (
'local' => ['Local Repository', '/var/lib/cvs'],
'mouarf' => ['mouarf devices', '/home/rancid/var/rancid/CVS'],
);
If the directory containing the cvsweb icons and css files is not in /var/www, you have to add a symbolic link :
# ln -s /usr/share/cvsweb /var/www/cvswebConfiguration history is now available via cvsweb at the following url :
# RANCID
# run config differ hourly
1 * * * * rancid /home/rancid/bin/rancid-run
# clean out config differ logs
50 23 * * * rancid /usr/bin/find /home/rancid/var/logs -type f -mtime +2 -exec rm {} \;
2. Using the command crontab -e (as rancid user)
# RANCID
# run config differ hourly
1 * * * * /home/rancid/bin/rancid-run
# clean out config differ logs
50 23 * * * /usr/bin/find /home/rancid/var/logs -type f -mtime +2 -exec rm {} \;
Now you need tacacs+ server to be launched when the machine start.#!/bin/sh #file /etc/init.d/tac_plus /usr/local/bin/tac_plus -C /etc/tac_plus.confMake it executable
# chmod 755 /etc/init.d/tac_plusCreate a symbolic link in rc2.d and rc3.d (depending your default init level, see /etc/inittab)
# cd /etc/rc2.d # ln -s ../init.d/tac_plus S92tac_plus # cd /etc/rc3.d # ln -s ../init.d/tac_plus S92tac_plusAdd /home/rancid/bin in your environment variables (for easier use of clogin)
# cd /usr/bin # ln -s /home/rancid/bin/clogin clogin
Important Note : It seems that clogin fails when there is a motd banner on cisco devices, if you want to be sure that rancid will properly backup your configs, make sure that there is no motd banner on your equipment.
You can add the alias rancid-rancid_group in the local mail server to receive the cvs diff by mail every time there is a configuration change.
# adduser --home /home/foobar foobarEdit the /etc/tac_plus.conf file and add the following lines
user = foobar {
login = des "the_DES_crypted password"
enable = des "the_DES_crypted password"
name = "Foobar User"
}
Note : You can prevent the user to be in priviliged mode if you comment or delete the "enable..." line.create the file /home/foobar/.cloginrc
# if the user dont have a privileged account
# add noenable * {1}
add user * {foobar}
add password * {pass_login} {pass_enable}
Note : Password are in clear text in this file, it has to be in chmod 600 and user foobar has to be owner of this file. Only root and foobar will be able to read it.Information :
clogin -c "sh ver" equipment_name > file.txtThis command will make the user logged into the equipment and will execute the "show version" command and will disconnect the user.
clogin -c "conf t;interface g0/1;no shut; end; wr mem" router1 router2This command will enable gigabitethernet port 0/1 on both router1 and router2.
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]
# RANCID
# run config differ hourly
1 * * * * rancid /home/rancid/bin/rancid-run0 * * * * rancid /home/rancid/bin/rancid-run[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]