Home > Blockchain >  How do I remotely execute a prespecified command with authentication across a local network on Linux
How do I remotely execute a prespecified command with authentication across a local network on Linux

Time:12-26

I have two Debian Linux servers on the same network. I would like server A to execute this command on server B: run.sh VARIABLE, and it needs to be able to process the output of said command - however, I do not want the contents of run.sh to be viewable to server A. I need there to be some kind of authentication between these two machines as well. Thank you all for your insight.

CodePudding user response:

Perhaps the easiest and fastest way you can accomplish this is to setup a standalone python REST server. On the client side you can use any client, even curl or python requests.

How to make a simple Python REST server and client?

As authentication it can be as simple as requiring a username and password in the JSON fields.

CodePudding user response:

Your specs are somewhat vague. Assuming that run.sh exists somewhere on server B, the easiest would be to use an ssh forced command and using a key-pair for the ssh connection.

You define the forced command in the ~/.ssh/authorized_keys on server B and pull the VARIABLE out of SSH_ORIGINAL_COMMAND in run.sh.

server A never gets to see run.sh, is able to pass arguments to run.sh. and running run.sh is all it can ever do ...

  • Related