So i need to execute one command but it will only run if i su to root (or sudo ) but I can't seem to figure out how to send the command to su to root
(i can log in and execute other commands with loginuser fine)
http://phpseclib.sourceforge.net/ssh/examples.html
My code as follows
<?php
include('Net/SSH2.php');
$ssh = new Net_SSH2('255.255.255.255',22);
if (!$ssh->login('loginuser', 'fakepassword')) {
exit('Login Failed');
}
echo $ssh->read('[prompt]');
echo $ssh->write("su\n");
echo $ssh->read('Password:');
echo $ssh->write("rootfakepassword");
echo $ssh->read('[prompt]');
echo $ssh->exec('cc get_wireless_status');
?>
I've also tried using the exec command to do roughly the same thing with no luck
any suggestions?
current revision of the code (doesnt work)
<?php
include('Net/SSH2.php');
$ssh = new Net_SSH2('255.255.99.74',22);
if (!$ssh->login('loginuser', 'password')) {
exit('Login Failed');
}
echo $ssh->read('loginuser@intranet:/home/login >');
$ssh->write("su\n");
echo $ssh->read('Password:');
$ssh->write("rootpassword\n");
echo $ssh->read('intranet:/home/login #');
$ssh->write("cc get_wireless_status\n");
echo $ssh->read('[prompt]');
?>
putty text of log in
login as: loginuser
[email protected]'s password:
Last login: Thu Feb 14 13:57:16 2013 from infong1045.lxa.perfora.net
Sophos UTM
(C) Copyrights by Astaro and by others 2000-2012.
For more copyright information look at /doc/astaro-license.txt
or http://www.astaro.com/doc/astaro-license.txt
NOTE: Any modifications done by root will void your support.
Please use WebAdmin for any configuration changes.
loginuser@intranet:/home/login > su
Password:
intranet:/home/login #
response from code on newest version
Last login: Thu Feb 14 14:00:00 2013 from 10.10.10.194 Sophos UTM (C) Copyrights by Astaro and by others 2000-2012. For more copyright information look at /doc/astaro-license.txt or http://www.astaro.com/doc/astaro-license.txt NOTE: Any modifications done by root will void your support. Please use WebAdmin for any configuration changes. loginuser@intranet:/home/login > Last login: Tue Feb 19 11:09:18 2013 from infong1045.lxa.perfora.net Sophos UTM (C) Copyrights by Astaro and by others 2000-2012. For more copyright information look at /doc/astaro-license.txt or http://www.astaro.com/doc/astaro-license.txt NOTE: Any modifications done by root will void your support. Please use WebAdmin for any configuration changes. loginuser@intranet:/home/login > su Password: intranet:/home/login # Last login: Tue Feb 19 11:09:23 2013 from infong1045.lxa.perfora.net Sophos UTM (C) Copyrights by Astaro and by others 2000-2012. For more copyright information look at /doc/astaro-license.txt or http://www.astaro.com/doc/astaro-license.txt NOTE: Any modifications done by root will void your support. Please use WebAdmin for any configuration changes. loginuser@intranet:/home/login > cc get_wireless_status -bash: /usr/local/bin/confd-client.plx: Permission denied loginuser@intranet:/home/login >