Kaseya Community

Plink ssh script with multiple usernames

This question has suggested answer(s)


I am trying to SSH to a sonicwall to do backups of the device.

I can manually ssh and then run the command no problem but the issue is I cannot use plink to automate it.

When you ssh to the Sonicwall the first prompt is Login as: - here you can pretty much type anything you want and then press enter you get User: - here you enter the admin username and then you enter the password and your in.

if i do plink -ssh -l admin -pw xyz  it uses admin for the first login but just sits then at the second login.

if I do admin@ -l admin -pw xyz it does the same thing.

Is there any way to get around this issue.


[edited by: mmartin at 10:29 AM (GMT -7) on 3-14-2012] change to question
All Replies
  • I tried to do this aswell, gave up for another day.

    Would love this if anyone fancies the challenge.

  • Try to login with the username of "snlwlcli"

  • I have used plink for automating SSH stuff extensively in the past... if Dan's suggestion doesn't work message me and I'll get with you directly to make a procedure that does what you want.

  • Hi Dan,

    No luck - when you say login using snlwlcli - i did snlwlcli@ but all it does is use that for the first login but still sits there at the second login...

    if you then add the -l admin to the commadn it just replaces the snl username with admin and back to square one again...

    Any ideas?

  • Pfft - I tried and am out of ideas.  I don't have a Sonicwall to test with.  Hopefully Ben can hook you up.

  • BUMP!!! - Anyone got any ideas?

  • We do a similar thing when logging into cisco devices and entering privilege/enable mode after the initial login.

    Specify a commands file, and type in your second login details there.

    This can be auto populated as the script runs (using echo commands to create your commands.txt file), or using a find and replace on your commands file so that your passwords aren't left on the system for an extended period of time.

    plink.exe -ssh <ip> -l <user> -pw <password> -m "C:\Commands.txt"

  • I'm trying to do this now and hitting the same issue, did anyone work out a solution?

  • i think i have this working, anyone still interested? - I'm still testing but I have it being ftp'ed to a server with a date attached so you can keep multipl copies.

    anyway let me know.

  • I would love to see the fix for this!

  • sorry for the delay been busy.

    There is quite a few steps involved and I haven't scripted them all yet but I will over the next few weeks hopefully.

  • Would also love an answer on this! Thanks

  • If you have it working i would like to see it

  • I set up a linux server using a bash script calling an expect script. Google, there is a nice article out there.
  • This thread is old but I finally got these stupid sonicwalls scripted. Now I'm trying to find all the places I searched and post this for anyone still looking. This isn't my code, I don't know where I found it but it works and you can make it do whatever. Just change the IP and login or whatever.

       @if (@CodeSection == @Batch) @then

       @echo on

       set SendKeys=CScript //nologo //E:JScript "%~F0"

       start \putty -ssh admin@IP.IP.IP.IP 22

       TIMEOUT /T 5

       %SendKeys% "admin{ENTER}"

       TIMEOUT /T 2

       %SendKeys% "password{ENTER}"

       TIMEOUT /T 2

       %SendKeys% "restart{ENTER}"

       TIMEOUT /T 2

       %SendKeys% "y{ENTER}"