[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 205
  • Last Modified:

How to execute a command by using a SSH connection on a remote IP and then return the results?

Hi Experts

How to execute a command by using by using a SSH connection on a remote IP and then return the results?

I'm facing a chalenge on how to do this by using PHP.

1. Fill  username/ password to be validated and only after validation  (doable).

2. Fill a textbox with an IP address  (doable).

3. Fill another textbox with a command to be executed in the IP machine (doable).

Could you point a way on how to do this ?
4. After that a SSH connection must be done, the command must to be executed  and return the results.

Obs.:
I am willing to work for an information security company and must to attend some questions previously.


Thanks in advance
0
Eduardo Fuerte
Asked:
Eduardo Fuerte
  • 3
  • 3
2 Solutions
 
ltpittCommented:
There are different ways to tackle this obstacle.
Do you think this kind of path might be interesting for you?

http://php.net/manual/en/function.shell-exec.php

Since you talk about information security company are there any specific requirements that have to be met?
0
 
Eduardo FuerteAuthor Commented:
Hi

I'm willing to start working for them... during this test phase it's up to me to find a solution.
I'm going to check.
0
 
ltpittCommented:
In this case we'd need to put some extra effort into it...
Please write back if the link is unclear or if you have further questions.

I am more confident with Python than with PHP but I bet better experts will pop up soon :)
0
[Webinar] Improve your customer journey

A positive customer journey is important in attracting and retaining business. To improve this experience, you can use Google Maps APIs to increase checkout conversions, boost user engagement, and optimize order fulfillment. Learn how in this webinar presented by Dito.

 
Ray PaseurCommented:
I think I would approach this from the perspective of a RESTful API.  Here is an article with some ideas.
https://www.experts-exchange.com/articles/12239/Introduction-to-Application-Programming-Interfaces.html

I think I would never let an external client request furnish an unfiltered command to run on my server.  However a RESTful API design could include a number of commands that the client could request and the server could execute safely.

But with that said, these links (and their links) might be helpful...
http://php.net/manual/en/book.ssh2.php
http://php.net/manual/en/ssh2.requirements.php
http://php.net/manual/en/ssh2.installation.php
http://php.net/manual/en/function.ssh2-connect.php
1
 
Eduardo FuerteAuthor Commented:
Hi

I found a library  phpseclib1.0.3 that at first view automatize this kind of operation.
Do you have any reference about it?
0
 
ltpittCommented:
It seems like Laravel is supporting ssh commands:
https://laravelcollective.com/docs/5.0/ssh
0
 
Eduardo FuerteAuthor Commented:
Thanks for help!
0

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now