11-11-2021 04:39 AM
Hi guys,
i wanted to know if there is a way to clear existing vty config on cisco devices like routers and switches?
i was thinking of automating it using an eem script but i git stuck in the actual logic to use for this
what i figured was using the output of sh run | grep ‘^line vty’ to a variable
then go conft and enter the first cli result of that output and somehow i should then negate all commands that were configured on that line vty , like no ‘cli result’ on all matches from sh run | s variable
this proves harder then i thought doh
this is what i got so far, it greps all configured vty lines and displays the config of them one by one:
event manager applet vty
event none
action 10 cli command “enable”
action 20 cli “term shell”
action 30 cli command “sh run | grep ‘^line vty’”
action 40 foreach line “$_cli_result” “\n”
action 50 set OUT “$line”
action 60 cli command “sh run | s $OUT”
action 70 wait 5
action 70 end
so next step would be to somehow clear all existing configuration of these vty lines
i hope someone can help me out
11-11-2021 07:15 AM
is it an option to "default" the lines ?
Many CLI commands also have a default form. By issuing the default command-name command, you can configure the command to its default setting. The Cisco IOS software command reference documents generally describe the function of the default form of the command when the default form performs a different function than the plain and no forms of the command. To see what default commands are available on your system, enter default? in the appropriate command mode.
you can try if "default line vty 0 4" works for your purpose
NB myself have used this only on interfaces "default interface Gi1/0/1"
11-11-2021 07:22 AM
Hi,
Hi Pieter, thanks but ,No, that unfortunately does not work with vty lines, this is what you will get:
R1(config)#default line vty 0 4
% Can't delete last 5 VTY lines
the problem i have is that we have several different configs for like vty 0 3, then another for line vty 4 and then finally yet another config on vty 5 till 15
Some of the lines need to be removed but not all, like for instance rotary command on line vty 4 but i cannot find a way a do it using a script
11-11-2021 07:24 AM
what are you looking to run every few hours and clear all vty line, only if you see certain VTy lines used ? what is the desired action ?
11-11-2021 09:27 AM
Hi Bandi,
thanks for asking, the desired action i want to achieve is this:
first determine what vty lines are configured
then check the config applied to these individual vty lines
Then remove all that config from those vty lines and replace it with 1 config for all vty lines
so the goal is to remove all configuration that is currently applied to the configured vty lines and replace it all with one common config for all vty lines
11-11-2021 09:30 AM
Hi Bandi,
thanks for asking, the desired action i want to achieve is this:
so the goal is to remove all configuration that is currently applied to the configured vty lines and replace it all with one common config for all vty lines
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide