Pregunta

I have to execute some commands on a remote Host, this host will be a "Router". I have never ever done work with RPC calls. Another big problem is that i have to execute these commands from a Django web based Application. Steps are following:

  • User open a page and choose a command for executing
  • User choose the remote host from a given list
  • User click on the execute button
  • In meanwhile Django will check the security Issue. It mean that it will authorize the remote Host using SSH
  • And the required command execute on the Host and sent back a message "Done!"

How i should start to work on this problem?

How should i create the SSH connection from user profile page to remote host?

For the security reason i want to create a connection using the user private key. I also find some related question but didn't got the right direction :)

¿Fue útil?

Solución

You should start with paramiko library, it has not so difficult api. And there are some examples bundled with library.

You can create ssh client, pass hostname, port, username, and user's key file in constructor, create shell, run your command and read commands output, stdout only. You can read stderr separately, or combine it with stdout.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top