I have an internal website that I am setting up server information links on. Basically, I have several linux servers that I want to keep info about. I want to be able to go to my internal webpage and have all of the servers listed there and if I click on one of the server buttons I will be taken to another page where info such as kernel, OS, memory, cpuinfo, etc. will be displayed.
To get this info I have a php script that will ssh to the server and gather the info through ssh commands. I have my ssh certificates set up to do this and it works. But the script is the same for all of my servers. The only difference being is the name of the server. I can have a script set up for each server so for instance I can have server_info_serverA.php, serverinfo_serverB.php, etc. However, since the script is the same except for the server name, I want to be able to have one script and then have this script login to whatever server depending on the server button clicked.
I have gotten my index file to pass the server name with the click. Here is a snippet of that code:
I want to add more submit buttons aobve and have the FORM ACTION be “server_info.php?Server=serverB”, etc.
The “server_info.php” script correctly sees the “Server” variable passed but I can;t get this variable to show up in an ssh command.
Here is the “server_info.php” code:
In the code above the echo statement correctly displays the name of the server. However, I can not get those “ssh” statements to work. The $Server value is not passing to these statements. When I run it the ssh doesn’t see the $Server variable and it gives me a “ssh: hostname: Name or service not known” error because it is trying to open an ssh connection to “hostname”. If I put the hostname of “serverA” in place instead of the $Server variable it works.
Does anyone have any ideas on how to get the variable to be read? I tried single-quotes, double-quotes, no quotes, etc. to no avail.