Automate extracting list of active VPN Tunnels to file
I need to provide another application a list of all of the active VPN tunnel gateway IP addresses every hour. To my knowledge the SonicOS API cannot provide information about active VPN tunnels.
So instead, I'm trying to build a tool that will connect to the CLI, run the "show vpn tunnels" command and save this to file. Then I'll need to write a tool to parse the file to extract the policy name and GW IP.
For the life of me I cannot get this to work--I'm using plink. I get it to connect, authenticate, etc. However, when I try to pass a command, it just results with "FATAL ERROR: Remote side unexpectedly closed network connection".
I know this is more of a plink issue (maybe?), but I'm hoping there is a solution out there to get this list of information automagically. Any ideas?
For specifics, here's my proof of concept plink command:
plink.exe -batch -m cmd.txt swconc -pw wxyz result.txt 2>&1
swconc is the putty profile that contains the IP, username, etc. I intend to switch to using public key instead of username/password, but first I need to prove this will work.
The cmd.txt is my command instructions. I'm literally trying the most basic command (help, in this case) and it does the same thing. My output file literally says "FATAL ERROR: Remote side unexpectedly closed network connection"