Wednesday, March 16, 2016

Cisco R&S: Autocommand Command

I came across a case where I needed a guy to, on occasion, check, the uptime of the switch.  I didnt want him to access anything else, since he really wasnt a switch guy at all.  But, I needed him to do this function instead of me doing it.  So, all I wanted him to do was to do the "show version", so he could check the uptime and report it to me if it looked like it had rebooted.  However, I didnt want this guy to have the ability to do anything else.  So, I used the "autocommand" command.  Below, you can see three commands.  First, I create the username/password.  Second, I set it where when John logs in, it will run the "show version" command for him.  Third, I tell it not to disconnect the session, so that he can view the uptime.

Core1(config)#username john pass j0yhnc6d
Core1(config)#username john privilege 6 autocommand show version
Core1(config)#username john nohangup
Core1(config)#exit

Here is what happens when John telnets in.  Notice that John never runs the command.  It runs it for him.  Also notice,  that it logs him out automatically after the command is run.  However, it doesnt close out the window, so that he can read the uptime.

User Access Verification

Username: john
Password:

Cisco IOS Software, C3560 Software (C3560-IPBASE-M), Version 12.2(35)SE5, RELEASE SOFTWARE (fc1)
Copyright (c) 1986-2007 by Cisco Systems, Inc.
Compiled Thu 19-Jul-07 18:15 by nachen
Image text-base: 0x00003000, data-base: 0x01100000

ROM: Bootstrap program is C3560 boot loader
BOOTLDR: C3560 Boot Loader (C3560-HBOOT-M) Version 12.2(25r)SEE4, RELEASE SOFTWARE (fc1)

Core1 uptime is 10 weeks, 4 days, 2 hours, 51 minutes
System returned to ROM by power-on
System image file is "flash:c3560-ipbase-mz.122-35.SE5/c3560-ipbase-mz.122-35.SE5.bin"

cisco WS-C3560G-48PS (PowerPC405) processor (revision F0) with 122880K/8184K bytes of memory.
Processor board ID FOC1203XXXX
Last reset from power-on
8 Virtual Ethernet interfaces
52 Gigabit Ethernet interfaces
The password-recovery mechanism is enabled.

512K bytes of flash-simulated non-volatile configuration memory.
Base ethernet MAC Address       : 00:1F:26:FD:XX:XX
Motherboard assembly number     : 73-10212-04
Power supply part number        : 341-0108-03
Motherboard serial number       : FOC1203XXXX
Power supply serial number      : DCA1152XXXX
Model revision number           : F0
Motherboard revision number     : B0
Model number                    : WS-C3560G-48PS-S
System serial number            : FOC1203XXXX
Top Assembly Part Number        : 800-26845-01
Top Assembly Revision Number    : B0
Version ID                      : V05
CLEI Code Number                : CNMWW00ARC
Hardware Board Revision Number  : 0x09

Switch   Ports  Model              SW Version              SW Image
------   -----  -----              ----------              ----------
*    1   52     WS-C3560G-48PS     12.2(35)SE5             C3560-IPBASE-M

Configuration register is 0xF


User Access Verification

Username:

3 comments:

  1. Learned something new today!! Thank you

    ReplyDelete
  2. Very cool Shane!! I was not aware of that feature...thanks!

    ReplyDelete
  3. Neat! Thanks for sharing that!

    ReplyDelete

Your comment will be reviewed for approval. Thank you for submitting your comments.