Solved

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

Posted on 2016-09-01
7
113 Views
Last Modified: 2016-09-03
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
Comment
Question by:Eduardo Fuerte
  • 3
  • 3
7 Comments
 
LVL 1

Expert Comment

by:ltpitt
ID: 41779896
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
 

Author Comment

by:Eduardo Fuerte
ID: 41779930
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
 
LVL 1

Expert Comment

by:ltpitt
ID: 41779947
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
Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

 
LVL 108

Accepted Solution

by:
Ray Paseur earned 450 total points
ID: 41779989
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
 

Author Comment

by:Eduardo Fuerte
ID: 41780621
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
 
LVL 1

Assisted Solution

by:ltpitt
ltpitt earned 50 total points
ID: 41781368
It seems like Laravel is supporting ssh commands:
https://laravelcollective.com/docs/5.0/ssh
0
 

Author Closing Comment

by:Eduardo Fuerte
ID: 41783281
Thanks for help!
0

Featured Post

Network it in WD Red

There's an industry-leading WD Red drive for every compatible NAS system to help fulfill your data storage needs. With drives up to 8TB, WD Red offers a wide array of solutions for customers looking to build the biggest, best-performing NAS storage solution.  

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Permalink issue in Wordpress archive 1 33
Hacked File Timestamps 4 50
php string masking 4 29
Is it okay to create multiple session variables with user data upon login 8 24
You ever wonder how to backup Linux system files just like Windows System Restore?  Well you can use Timeshift in Linux to perform those similar action.  This tutorial will show you how to backup your system files and keep regular intervals. Note…
The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
The viewer will learn how to dynamically set the form action using jQuery.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now