Crash893
Crash893

Reputation: 11702

Get info from my router VIA SSH CLI from a php page

All,

I'm fairly new to php (simple forms and hello world stuff)

I'm trying to create a page that when loaded will go out grab some text information from a SSH session on my router parse it out and display it

The general idea would be

connect to (ip address, port) send line (loginuser + Password) send line (su to root + password) send line (command) receive text from command (string X)

parse x and display stats as html on page

I've seen a few tutorials on how to install libraries from ubuntu but my host is godaddy so i wont have access to install anything in that manner (i only have simple ftp access)

I'm looking for a simple simple simple ssh client and hopefully a small example on how to use it (send commands and retrieve text)

Thanks if you can help

Upvotes: 0

Views: 966

Answers (2)

tkorkunckaya
tkorkunckaya

Reputation: 163

Ok, just for learning purposes, you can shell_exec on your box to connect to remote host with ssh, run a command and return response, evaluate and make some nice stats:

shell_exec("ssh [email protected] run_your_command"); http://www.php.net/manual/en/function.shell-exec.php

I would use phpseclib (http://phpseclib.sourceforge.net/), a pure PHP SSH implementation, or if is available on your host use SSH2 extension. http://www.php.net/manual/en/function.ssh2-exec.php

Upvotes: 2

napolux
napolux

Reputation: 16094

PHP is not the right tool in my opinion, you can achieve better results with expect and some bash stuff.

expect is a good tool for command line activities. Try to have a look

Upvotes: 0

Related Questions