php and telnet merging

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
depaolo2001
Forum Newbie
Posts: 2
Joined: Thu Aug 04, 2005 3:38 am

php and telnet merging

Post 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... (.!_!.)
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post 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..
depaolo2001
Forum Newbie
Posts: 2
Joined: Thu Aug 04, 2005 3:38 am

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

Post 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...
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Post by onion2k »

You'll never learn anything if you just try to get other people to do the work for you.
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post 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.
Post Reply