Executing a command upon user login
Cisco IOS long had the autocommand option by which you could attach any command to a username and have it execute after successful login. For example, username x autocommand show ip interface brief command would configure the router to display the interface status after someone would log in as user x.
After the autocommand is executed, the user is logged out and the session is disconnected, unless you configure the username user nohangup option, which causes the session to remain active, giving the operator another login prompt.
After the autocommand is executed, the user is logged out and the session is disconnected, unless you configure the username user nohangup option, which causes the session to remain active, giving the operator another login prompt.
I've been playing around with this some and have made an interesting observation. If I configure the line(s) with 'login local' then the autocommand function works okay. However, if I configure line authentication via a AAA login method (even though the AAA method specifies the local user database), the autocommand never executes. Here's an example config of the latter:
username IP password IP
username IP autocommand show ip int br
username CISCO password CISCO
!
aaa new-model
aaa authentication login CON line
aaa authentication login VTY local line
!
line con 0
login authentication CON
line vty 0 4
login authentication VTY
I haven't been able to find anything in the documentation that helps me understand this behavior...can you provide any insight?
Thanks!
Thanks again for the response, and this blog site!
Jeff
line vty 0 4
login local
autocommand terminal monitor
autocommand-options nohangup
username engineer priv 15 secret mypassword
:)
YOU ROCK! THANKS!
autocommand terminal monitor
autocommand-options nohangup
username x priv 15 secret y
username x autocommand disable
any idea?