Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SSH Commands - Automate/script

Tags:

command

ssh

I looked around and couldn't seem to find an answer to my questions. I am looking for a way to automate/script a set of SSH commands to export config files from our Sonicwall Routers. I have the sonicwall commands set but i am having trouble automating them. When I connect to one of our sonicwalls with SSH I get prompted with for a user. I type in the username and then get prompted again for a username and password. Once I enter the correct information, i can execute the export of the config. Below is an example of layout. Please let me know if anyone knows of a way to automate/script this. thanks in advance

User:%username%

User: %username%

Password: %password%

command: export preferences ftp %ftpserver% %ftpuser% %ftpPassword% backup.exp

like image 909
Mpit52 Avatar asked Aug 22 '26 21:08

Mpit52


2 Answers

Use keys instead of userid/password. http://pkeck.myweb.uga.edu/ssh/

like image 146
mike jones Avatar answered Aug 26 '26 06:08

mike jones


The router expects an SSH username, but not a password. Once you 'log in' with the username via SSH, the Sonicwall will prompt for a username and password using its internal authentication mechanism. Treat those prompts just like any other within the Sonicwall CLI. You can pass your commands (including username/password) via stdin like this, for example:

(echo -e 'admin\npassword'; sleep 1; echo tsr; sleep 2; echo logout; sleep 1) | ssh [email protected]

like image 32
PunctuallyChallenged Avatar answered Aug 26 '26 07:08

PunctuallyChallenged



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!