LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   bash script to work on server (https://www.linuxquestions.org/questions/programming-9/bash-script-to-work-on-server-4175735130/)

sag2662 03-22-2024 03:36 AM

Quote:

Originally Posted by metaed (Post 6491096)
Yes, it was mentioned that it's a terminal server. In the past, I have sent remote commands to execute on a Cisco switch over a TELNET circuit. For example to backup the configuration:
Code:

(
echo enable                    ; sleep 0.1
echo "$secret"                  ; sleep 0.1
echo terminal length 0          ; sleep 0.1
echo show running-config        ; sleep 30.0
echo show startup-config        ; sleep 30.0
echo quit                      ; sleep 0.1
) | telnet $ip >$out 2>&1

Of course this is a terrible idea nowadays. The enable-secret goes over the wire as plaintext, and somebody is always listening (or that is what you should assume). OP quite understandably wants to do it over an ssh-encrypted circuit.

Thanks for this, I will also try this, but with telnet can we also make changes to the configuration ?

metaed 03-22-2024 12:26 PM

Quote:

Originally Posted by sag2662 (Post 6491174)
I will also try this, but with telnet can we also make changes to the configuration ?

You can type anything you want to the remote, including answers to prompts. In the example above:
Code:

echo enable
echo "$secret"

the "enable" prompts for the enable-secret, which is given on the next line.

But don't use telnet because the entire exchange goes over the network as plain text. Figure out how to do it over ssh.


All times are GMT -5. The time now is 08:51 PM.