ssh login to multiple servers using a variable

Hello:

I am facing an issue and I seem not to be able to find my way out of it.
When I send the ssh command to the localhost, it works, but when sending it to a different server, it doesn’t. I can ssh into the units manually and send the commands manually, but no using the PHP Form depicted here…

The form collects the server name and the command to send, then opens the PHP file to execute the ssh commands to the specified server and command.

What am I doing wrong??
Please help

Here is the two pieces of code…

-=-=-=-=-=-=-=-=

Maintenance Tool

Maintenance Tool

 

Main Units:

Unit name: (Do not use capital letters)
Send command:
reboot
Quit Safari
Documents Full

 

 

-=-=-==-=-=-=-=-==-=-=-=-=-=-==-=-= <?php $Mplayer = $_POST["player"]; $command = $_POST["radio"]; ?>

You are about to modify the

<?php echo "$Mplayer"; ?>

player by sending the

<?PHP $selected_radio = $command; print $selected_radio; $connection = ssh2_connect($Mplayer, 22); ssh2_auth_password($connection, 'user', 'password'); $stream = ssh2_exec($connection, $command); print $stream; ?> command.

ok lets say this works and you say from localhost it does but where is your ip that you are putting in it to make it go to the other server because i see no include a connection file

Thank you for your reply…

If you look into the code, I use the $Mplayer as my variable, the units that I am attempting to work with are distributed nationwide, and they are about 1550 units, each one is identified by its DNS name.

In the HTML page, I ask for the unit name, which it turns to be the $Mplayer variable value, which via DNS has an IP value too.

at this point, the intention is to use the “admin” user @“MPlayer” value (admin@Unit234).

When I use my ssh client, I can log into the units no problem with that same information, from the server or an other ssh client in the network.

During my tests, I changed the variables to a specific IP in the network, and it would simply not Authenticate and remain spinning until time out.

I wonder what could be causing this, since it does work within the localhost…

If I give $Mplayer the value of localhost, it works without a hitch.

I hope this clarifies the post a bit better.

thanks again

HTakeuchi

right ok so localhost meaning a wampp or xampp web server on windows if i read correctly

/Users/e12345/Documents/*.*

so localhost is while you are looking at your windows

and the other server is a windows also right

does the web server have the right permissions

Sponsor our Newsletter | Privacy Policy | Terms of Service