Tell me more ×
Network Engineering Stack Exchange is a question and answer site for network engineers. It's 100% free, no registration required.

Anyone ever done this before? Trying to use plink.exe to execute a commands.txt file remotely and pull the running config. Unfortunately using the -m argument and specifying a simple command.txt file like this:

Command

plink.exe -ssh -2 -l test -pw password 192.168.1.1 -batch -m command.txt

Contents of command.txt

enable
EnablePassword
show run

Causes the thing to throw an error (invalid autocommand) because it executes all of it as one big command. Every piece of documentation I can find on the commands batch files just shows a simple text file with the various commands on separate lines.

If this technique wont work how do you folks usually automate config backups? I was leaning towards a script because it's free. I know there are paid tools out there that will do it for you. Also need to be able to execute in an environment where we may not be able to actually install and configure an app.

share|improve this question
 
I would re-phrase the question to avoid it being closed ,as this group is not about software support –  IanK Jul 3 at 16:12
 
Understood, thanks for the advice. I am primarily trying to determine the best way to automate config backups from IOS devices. Not only for direct support on plink, although I had assumed some of the users here may have had experience with the tool. –  Bill Gurling Jul 3 at 16:53
 
I'm putting this on hold because as-phrased, this question is too broad and has too many possible answers. –  Mike Pennington Aug 18 at 11:21
add comment

closed as too broad by Mike Pennington Aug 18 at 11:22

There are either too many possible answers, or good answers would be too long for this format. Please add details to narrow the answer set or to isolate an issue that can be answered in a few paragraphs.If this question can be reworded to fit the rules in the help center, please edit the question.

7 Answers

have a look at Rancid ( open source) , see summary below from Shubbery Networks website

RANCID monitors a router's (or more generally a device's) configuration, including software and hardware (cards, serial numbers, etc) and uses CVS (Concurrent Version System) or Subversion to maintain history of changes.

RANCID does this by the very simple process summarized here:

  • login to each device in the router table (router.db),
  • run various commands to get the information that will be saved,
  • cook the output; re-format, remove oscillating or incrementing data,
  • email any differences (sample) from the previous collection to a mail list,
  • and finally commit those changes to the revision control system

If your only running windows then Kiwi CatTools, depending on your network size as the free version is limited to 20 devices.

share|improve this answer
 
Thanks for the response, I have looked at RANCID but being that it's Linux only I don't believe it is a good fit for this particular use case. Have not seen kiwicat tools, will look into it. –  Bill Gurling Jul 3 at 16:51
add comment

Another way would be to use IOS's built-in kron facility, quickly stole this from a show running-config from one of my routers:

kron occurrence config-backup at 13:00 recurring
 policy-list config-backup

kron policy-list config-backup
 cli show running-config | redirect ftp://username:[email protected]/router1.confg
share|improve this answer
add comment

If you are just looking for a tool to automate configuration backups from IOS devices, maybe the archive feature in IOS is what you are looking for.

Next is a configuration sample to backup running configuration to an FTP server once a day (1440 minutes) and every time save running config to startup:

archive
  path ftp://username:password@serveraddress/switchname
  write-memory
  time-period 1440
  exit

Of course, you need to have an FTP, TFTP or similar server running in your network and reachable from the management interface of the devices.

share|improve this answer
add comment

When I need an script with Plink, I run use the followed command.

plink.exe -ssh -pw <PWD> -noagent -m commands.txt -batch <USR>@<IP>

Here an example script

For automatic config backup, I would recommend you to use the archive feature or Rancid.

share|improve this answer
 
Yes, in this way there is security issue. For a proper script we should create an user with limited priv. but I'm not sure if a user on read-only priv. ("show" commands) can have access to the running-config, in the past I've dificulties on this. And the script have a limitation of having to accept the ssh fingerprint key previously. This is solving execute the plink.exe line code on command-line before. We use this kind of script here in company for some administrative staff can take info on CMTS/Router in a brainless way :). –  cdq74cn Jul 4 at 8:55
add comment

Your problem is that you're trying to use plink.exe for interactive prompts (i.e. to recognize when the router asks for an enable password), but plink.exe was never intended to do that... all plink.exe can do is send some commands to an ssh server without understanding anything about prompts or errors that the router will throw.

The most reasonable way for you to solve this problem is to create a username that can login directly at Cisco IOS priv level 15, and only put this in command.txt:

show runn

Having a username that logs in directly at priv 15 removes the necessity for you to have to interact with a Cisco IOS prompt.

The final solution will not look very different than what you are doing now...

plink.exe -ssh -2 -l <a-user-w-priv-15> -pw <some-password> 192.168.1.1 -batch -m command.txt
share|improve this answer
add comment

I wrote something to do config versioning called Project Illuminati - https://github.com/Olipro/Project-Illuminati

Works happily under Windows or Linux, it'll execute arbitrary commands over SSH (therby making it usable with just about any platform that has SSH) and dump the file into whatever path you deem appropriate, all versioned within a Git repo.

If you want it to run at scheduled interviews, just use cron under Linux or Scheduled Tasks under windows.

share|improve this answer
add comment

I had the same idea of automatically backing up the switches.

I use SSH with public key authentication and then copy the running config (or the startup config) via scp:

    scp ${sw_username}@${sw_ip}:startup-config $CONFDIR/$sw_name.conf
share|improve this answer
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.