Page 1 of 1

sshpass

Posted: Wed Dec 04, 2019 4:00 am
by atrac
Hello, I have almost finished my setup.
After fighting with usb sticks, I bought a second hand industrial router which has no wifi, it's only a gateway LTE->ethernet. I paid it less than a new usb stick.
I attached the wan interface of gargoyle router to this gateway, in order to apply the daily quota.
Everything is ok, I am still missing one feature.
The gateway has 2 sim slots, but just one modem. It does not have any function to switch based on quota.
Therefore, I have to do this in the gargoyle system: when quota is over, or maybe on certain sites ping fail, a script will run and it is supposed to connect to the gateway through ssh, enter some commands to manually switch to sim2 (or back to 1), and exit.
I think I need sshpass to do this. Is it possible to install it? Is there another way?

Thanks.

Re: sshpass

Posted: Wed Dec 04, 2019 5:39 am
by RomanHK
the "sshpass" package does not support OpenWrt (Gargoyle). T̶r̶y̶ ̶u̶s̶i̶n̶g̶ ̶a̶n̶o̶t̶h̶e̶r̶ ̶s̶u̶p̶p̶o̶r̶t̶e̶d̶ ̶O̶p̶e̶n̶W̶r̶t̶ ̶p̶a̶c̶k̶a̶g̶e̶ ̶l̶i̶k̶e̶ ̶"̶o̶p̶e̶n̶s̶s̶h̶-̶c̶l̶i̶e̶n̶t̶"̶.

EDIT: Bad idea, I'm sorry.

Re: sshpass

Posted: Wed Dec 04, 2019 5:42 am
by Lantis
You need to SSH from Gargoyle to the other router/modem?
Gargoyle has a built in SSH client.

You need to SSH from the other router/modem to Gargoyle?
Gargoyle has a built in SSH server.

I'm not sure what scenario you're trying to cover, but they are both sorted without installing anything. Or do i not understand what you are trying to do?

Re: sshpass

Posted: Wed Dec 04, 2019 6:44 am
by atrac
Lantis wrote:You need to SSH from Gargoyle to the other router/modem?
Gargoyle has a built in SSH client.
Yes exactly
Lantis wrote: I'm not sure what scenario you're trying to cover, but they are both sorted without installing anything. Or do i not understand what you are trying to do?
My understanding is that you cannot call ssh from a script (which is what I need to do) since just writing the password in the script will not work. This is why you need sshpass.
Correct me if I am wrong.

Maybe I can use public key authentication? Is it possible to do that?

Re: sshpass

Posted: Wed Dec 04, 2019 7:34 am
by Lantis
OK, i understand. For use in scripting i haven't had anything to do with this.

Re: sshpass

Posted: Wed Dec 04, 2019 9:56 am
by RomanHK
All I found is a friendly compilation:

Developer website: https://sourceforge.net/projects/sshpass/

Architectures:
aarch64_cortex-a53: https://repo.turris.cz/hbs/mox/packages ... ex-a53.ipk
arm_cortex-a9_vfpv3: https://repo.turris.cz/hbs/omnia/packag ... _vfpv3.ipk
powerpc_8540: https://repo.turris.cz/hbs/turris1x/pac ... c_8540.ipk
mips_mips32: https://rureka.com/files/sshpass/sshpas ... mips32.ipk

Packages should be compatible with Gargoyle 1.11.0 and 1.12.0, but I haven't tried them.

If you don't find your architecture, you'll have to ask someone to compile the package.

Good luck ;) ...

Re: sshpass

Posted: Wed Dec 04, 2019 10:14 am
by atrac
Ok then I can do in this way:
attach to the network a raspberry pi.
From the raspberry I will query the gargoyle, see if half of the quota has been reached; if positive, then connect to the LTE router via ssh and issue the switch to sim 2 command. At the end of the quota month revert to the sim 1.
In raspberry I can install expect or some other scripting that will do the job. Just some waste of power to keep it on all the time.
Now, the question is, how do I query the gargoyle from raspberry to know how much traffic has been used?

Re: sshpass

Posted: Wed Dec 04, 2019 4:05 pm
by Lantis
The "print_quotas" command is probably what you want.