2009
do_auth & IOS-XR
ios-xr bug: sends blank ip in conf t. tac_plus really should send an "unknown" for this. I'd submit a patch, but I'm no good at C. job == networker, job != programmer. Heasley strongly disagrees with me on this though. Even though I'm obviously right, I suppose someday I'll have fix the parsing to ignore any options not sent. ;-) Till then: v1.4: (Removed)
Simple workaround: -i $address -fix_crs_bug. I advise you use it even if you don't use ios-xr.
Version 1.5 Feb 28 2011 Corrected a stupid mistake in the example. (python do_auth.py | less) Thanks to aojea. v1.5 (Also removed - scroll up for latest version)
Note: I haven't done any work on this because, to the best of my knowledge, I'm the only one who uses it. If you find it useful, write a quick post!
Easier Tacacs Configurations with do_auth
We've gone over how you can make your tacacs configuration really secure but complicated. Let's show how do\_auth can actually make configuration easier. It's much easier to edit the do\_auth.ini file than the tac\_plus.conf file. In fact, we can make adding a default user as easy as typing "adduser".
I would post the compiled code, but it's too difficult to get a hold of John these days. (Something about a baby, I dunno) It's trivial to compile:
dan@dan-desktop:~$ python
Python 2.5.2 (r252:60911, Jul 22 2009, 15:35:03)
[GCC 4.2.4 (Ubuntu 4.2.4-1ubuntu3)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import py\_compile
>>> py\_compile.compile("do\_auth.py")
>>> quit()
First, a starting tac\_plus.conf file. Which, we'll never have to edit again:
# My simple tac\_plus config that never needs to change
key = my\_key
accounting file = /var/log/tac\_plus.acct
default authentication = file /etc/passwd
user = DEFAULT {
member = do\_auth\_access
}
group = do\_auth\_access {
default service = permit
service = exec { priv-lvl = 15
idletime = 10 }
enable = file /etc/passwd
after authorization "/usr/bin/python /root/do\_auth.pyc -i $address -u $user -d $name -l /root/log.txt -f /root/do\_auth.ini"
}
Most important - after authorizaion line is one line, not two. The $ means it wrapped.
Now, we add homer and give him access to some show commands. Fist, we do a adduser homer on linux to add the user. This way, when the user wants to change is password, he can any time he wants to with passwd. Next, we edit the do\_auth.ini file
[users]
homer =
few\_commands
[few\_commands]
host\_allow =
.*
device\_permit =
.*
command\_permit =
show users
show int.*
show ip int.*
show controllers.*
And, you're done. Well, I'd add some tabs to each command that got stripped above(blogs/wiki's can be annoying), but that's about it.
Let's compare that to the tac\_plus.conf config:
user = homer {
member = limited\_access
}
group = limited\_access {
default service = deny
acl = limited\_acl
service = exec {
priv-lvl = 15
idletime = 10
}
cmd = show {
permit "running-config.*"
permit "ip int*"
permit "inter.*"
permit "controllers.*"
}
In my small do\_auth python program, we have no permits, no “”, and no {}. Much easier and the no need to restart the daemon. To add an admin user is even easier. Adduser admin in linux, then add:
admin =
admin\_user
[admin\_user]
host\_allow =
.*
device\_permit =
.*
command\_permit =
.*
So, our final config is very easy:
[users]
homer =
few\_commands
admin =
admin\_user
[few\_commands]
host\_allow =
.*
device\_permit =
.*
command\_permit =
show users
show int.*
show ip int.*
show controllers.*
[admin\_user]
host\_allow =
.*
device\_permit =
.*
command\_permit =
.*
As if this weren't easy enough, let's say 99% of your users are these limited access users. Wouldn't it be nice to just do an adduser and be done without any config modification? All we need is a default user. In our example above we would change to this:
[users]
default =
few\_commands
[few\_commands]
host\_allow =
.*
device\_permit =
.*
command\_permit =
show users
show int.*
show ip int.*
show controllers.*
Now, whenever we do an adduser, it automatically gets this level of access.
From here, we can make it as simple or as complicated as we want. Restrict them to certain device, make them connect from connect from certain IP's, ect. We can maybe even begin to work on a web front end. (Maybe someday when I get time.....)
-Dan Schmidt
Granular Tacacs Control (Yes, you can do multiple groups)
By using an authorization script, we can make tac\_plus to do very granular authentication, having different permissions granted to different switches defined by user, source IP and device IP. However, writing/editing a script to change access can be difficult. Hard coded authorization scripts are not very flexible, hence, I decided to implement a python program to facilitate flexibility. It is now included in the tac\_plus package. Configuration is fairly simple; as an example, let's say I wanted to have user Homer have full access to 192.168.1.1 and 10.1.1.0/24, but only do show commands for everything else in 10.0.0.0/8. For the heck of it, let's say we only want Homer to connect from 192.168.1.0/24, but never 192.168.1.4, which host can only do the show commands. The config file would simply be as follows:
[users]
homer =
simpson\_group
television\_group
[simpson\_group]
host\_deny =
192.168.1.4
host\_allow =
192.168.1.*
device\_permit =
192.168.1.1
10.1.1.*
command\_permit =
.*
[television\_group]
host\_allow =
192.168.1.*
device\_permit =
10.*
command\_permit =
show.*
Example line to put in tac\_plus user or group: after authorization "/usr/bin/python /root/do\_auth.pyc -i $address -u $user -d $name -l /root/log.txt -f /root/do\_auth.ini" (that's all ONE line)
On my server, I set homer's password file to /etc/passwd and enable cracklib. Homer can change his password any time he wants just by logging to Linux and typing passwd – he does not need root access. Homer is also forced to pick a secure password, and has different access based on different devices. Given these abilities, combined with the quick administration, tac\_plus makes purchasing Cisco's tacacs server seem like a waste of money.
In the future, I may alter the program to have the ability to send back additional av-pairs, and/or completely new av-pairs. However, currently I simply don't need this feature as I pass these pairs back to tac\_plus. The source code is very simple and is GPL'ed for all to see at: http://pastie.org/506002 and is available in compiled/ready to use form here. For more instructions, you can download this compiled pyc and type “python do\_auth.pyc” If I ever get time, I may consider a gui or web interface.
Update: New version 1.2 Fixed pix. Also, apparently there is a bug in the pix that makes it necessary to add a 0.0.0.0 to your allowed hosts.
-Dan Schmidt