Page 1 of 1

php and telnet merging

Posted: Thu Aug 04, 2005 4:06 am
by depaolo2001
plz help... any1 out der... nid help regarding using telnet functions in a php program... for example... changing a directory,creating files, ejecting and shutting down by use of a php program... thnx... (.!_!.)

Posted: Thu Aug 04, 2005 5:20 am
by timvw
All you need is http://www.php.net/fsockopen and then read/write from that socket..

Btw, there is also a SSH2 extension..

thnx 4 d reply... cre 2 help some more?...

Posted: Thu Aug 18, 2005 3:59 am
by depaolo2001
i wud like to thank you 4 your reply sadly am not adept in using PHP yet and i wouldnt be able to fully understand and use SSH in such a short period... if you would be kind enough to provide a sample program that incorporates the use of SSH in shutting down the PC... as of now,we are concluding that what we need is something that of "telnet" that uses terminal in manipulating the PC... please i need it badly... hoping your kind reply... thanks in advance...

Posted: Thu Aug 18, 2005 4:17 am
by onion2k
You'll never learn anything if you just try to get other people to do the work for you.

Posted: Thu Aug 18, 2005 6:30 am
by timvw

Code: Select all

<?php
$connection = ssh2_connect('shell.example.com', 22);
ssh2_auth_password($connection, 'root', 'password');

$stream = ssh2_exec($connection, 'shutdown -h now');
?>
But i would suggest that you use public/private keys for authentication and give a user rights to perform /sbin/shutdown instead of doing it as root herself.