Accessing 100+ ip's via ssh

Hello everybody,

I recently ran into the problem of having to change the configuration of about 150 vpn clients.
They are all conntected to a RouterOS system runnning as ovpn-server.
To tackle the problem not having to access every client manually i tried the following script

:foreach item in=[ /ip address find ] do={ :local network [ /ip address get $item network ];
/system ssh user=username address="$network" "/tool fetch address=VPN.VPN.VPN.VPN user=user password=password mode=ftp src-path=/conf.rsc dst-path=/conf.rsc
/import conf.rsc
/quit"
}

The problem i ran into is that it crashes halfway through the list and i can’t retrace where and don’t get why.
Has anyone any idea as to why this script would stop working?

Best Regards

Should you pause after the quit … give it some time?

Well that would probably be a good idea, but I don’t have the faintest of ideas how to accomplish that.
Could you give me a hint?

Related to the subject: Would it be possible to create somekind of output to a file for example to be able to track progress and in case of an error know which clients weren’t handled?

I’m guessing it’s erroring out because it’s trying to ssh into every IP address listed in IP Addresses, it hits an address it cannot get to, so the script errors out. The scripting language is not good at catching errors and moving on. So you may want to narrow down what it finds in the first line by specifying dynamic addresses, or looping through the PPP interface list and getting the caller ID instead.

You can add a delay by this command “:delay ” if desired.