This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

SFOS 18.0.3 ssh scripted restart IPsec tunnel service with plink

I have a problem with two XG 106 on SFOS 18.0.3
Both have a routing-based IPsec to another virtualized XG with SFOS 18.0.3
Both XG 106 are connected to VDSL lines with variable IPs and every night the XGs change IP.
Unfortunately after the IP change the tunnels come up again but the tunnel interfaces stay down and the XGs seem not to notice it.
Only a restart of the IPsec tunnels on the hardware XGs does reactivate the interfaces properly.

Alternatively through SSH console the restart of the VPN service.

On this basis I tried creating a script that uses PLINK to autmatically connect to the XGs and restart the VPN service.

Unfortunately, it looks like the scripted acces does work differently from the normal putty access.

On the putty session after login I get the menu options and then it's option 6, then option 2

Unfortunately when I try and script this with plink it doesn't work.

I get an "access granted" but from the logs I notice that I do net get a menu put apparently just a shell/command
And the passing of the "6" parameter just returns an error.

Here the screenshot from the session.

Apparently the session is beeing closed even before the first parameter is sent.

Is there a way to do this properly?



This thread was automatically locked due to age.
Parents
  • Solution found.

    I still don't know how to do it with powershell but have got a perfectly working solution using the Putty fork Kitty

    Kitty allows to save login data and commands into the sessions and save them. It can be easily started through command line and is easily portable as there is a was to save the settings not in the registry but on.

    On loading it looks very much like Putty

    The detail lies in the "Data" folder under "Connections"

    Here one can enter the login and command entries.

    For the restart of the VPN services the functioning command series is:

    6\n\p2\n\py\n\n\p0\p\p\p\p\p\p\p\p\p\p\p\p\p\p\p\p\p\p\p\p\p\n0\n0\n0\n

    Where "\n" is for new command and "\p" for a 1-second pause.
    All the "\p" after the "y\n\n" for the confirming of the VPN restart are there because it takes time for the restart to finish.
    And only afer the restart has finished follow the commands to exit the menu and close the session.

    Once the session is tested and saved it can be loaaded through a batch file

    kitty.exe -load {session name} -auto-store-sshkey 

    After that is was just a matter of creating a recurring task on the customer's windows server

Reply
  • Solution found.

    I still don't know how to do it with powershell but have got a perfectly working solution using the Putty fork Kitty

    Kitty allows to save login data and commands into the sessions and save them. It can be easily started through command line and is easily portable as there is a was to save the settings not in the registry but on.

    On loading it looks very much like Putty

    The detail lies in the "Data" folder under "Connections"

    Here one can enter the login and command entries.

    For the restart of the VPN services the functioning command series is:

    6\n\p2\n\py\n\n\p0\p\p\p\p\p\p\p\p\p\p\p\p\p\p\p\p\p\p\p\p\p\n0\n0\n0\n

    Where "\n" is for new command and "\p" for a 1-second pause.
    All the "\p" after the "y\n\n" for the confirming of the VPN restart are there because it takes time for the restart to finish.
    And only afer the restart has finished follow the commands to exit the menu and close the session.

    Once the session is tested and saved it can be loaaded through a batch file

    kitty.exe -load {session name} -auto-store-sshkey 

    After that is was just a matter of creating a recurring task on the customer's windows server

Children