Php ssh2 sunucu yonetme
1
●1.007
- 17-09-2014, 20:19:10

<?php class FastSSH2 { var $baglanti; var $yayin; public function __construct($ip, $user, $pass, $port=22) { if(!function_exists('ssh2_connect') || !function_exists('ssh2_auth_password') || !function_exists('ssh2_exec')) { exit('SSH2 eklentisi bulunamadı.'); } $this->baglanti = @ssh2_connect($ip, $port); @ssh2_auth_password($this->baglanti, $user, $pass); } public function komut($komut,$b=true) { $this->yayin = @ssh2_exec($this->baglanti, $komut); @stream_set_blocking($this->yayin, $b); return @stream_get_contents($this->yayin); } } ############################################# # kullanımı ############################################# $FastSSH2 = new FastSSH2('sunucuip','root','rootsifresi',22); /* 22 ssh port */ # apache ve mysqli yeniden başlatalim $FastSSH2->komut('/etc/init.d/httpd restart'); $FastSSH2->komut('/etc/init.d/mysql restart'); # sunucu reboot $FastSSH2->komut('/usr/bin/reboot'); # gibi... ?>

