D
D
demonca132021-06-08 20:39:52
bash
demonca13, 2021-06-08 20:39:52

How to remotely reboot Grandstream GXP2200 every day?

I have a network where everything is distributed over VLANs, there is an Asterisk server and IP phones, of which 5 Grandstream are with the leaders, the phones are visible only to Asterisk. The task is this, you need to reboot these 5 Grandstreams every day, but the phone itself does not have such a function, but there is a reboot method via SSH with a simple reboot command. But there is a small problem with the script, since Asterisk is installed on Centos 5.2, where updates and installation of packages are strictly prohibited, I cannot use expect and sshpass.

What methods do you recommend?
Thanks in advance everyone.)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Shitskov, 2021-06-08
@demonca13

In such a situation, it might work with such a "hack". Once upon a time they used it on a project in a somewhat similar situation.
First you need to create a script that displays the password using echo

#!/bin/sh
echo "secret_Grandstream_pass"

For example, let's say the script will be stored in /home/root/grandstream_pass
You need to assign execution rights to this script chmod u+x /home/root/grandstream_pass
Then create another script that executes a remote ssh command
#!/bin/sh
# Заставляем ssh считать что у нас нет дисплея, что поспособствует тому, что ssh Не будет запрашивать пароль
export DISPLAY=:0

# Тот самый скрипт с паролем
export SSH_ASKPASS=/home/root/grandstream_pass

# Выполняем ssh. setsid создаст новый сеанс без контролирующего терминала, что так же способствует тому, чтобы ssh не запросил пароль
setsid ssh [email protected] "reboot"

Instead of the second script, you can use a one-liner
DISPLAY=: SSH_ASKPASS=/home/root/grandstream_pass setsid ssh [email protected] "reboot"
или
echo nothing | DISPLAY=: SSH_ASKPASS=/home/root/grandstream_pass ssh [email protected] "reboot"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question