많은 서버를 관리할때 일일이 ssh접속해서 명령어치고 빠지고 하기 귀찮을때 쓰면 좋습니다
요거는 ssh2 는 지원안됍니당 ~
실행파일은 php로 작업의도에 맞게 응용하시면 됩니다 아래는 기본샘플입니당~
<?
require_once ('test_db.php'); //디비 커넥션
require_once ('ssh_in_php.php');
$db = new TestDB;
$cmd=null;
set_time_limit(0);
$qry = "select * from ip_table"; //루프돌리는 방법은 개인스탈에 따라~
$db->query($qry);
while($db->next_record())
{
try
{
$host = 아이피;
$port = 포트번호;
$user = 계정아이디;
$password = 계정패스워드;
$su = 루트패스워드;
$ssh = null;
$ssh = new SSH_in_PHP($host,$port);
$ssh->connect($user,$password);
$ssh->write("su -\n\n");
$cycle = true;
$result="";
while ($cycle) {
$data = $ssh->read();
echo $data;
if (ereg('\]$',$data)) {
// $cycle = false;
}
if (ereg('\]#',$data)) {
$cycle = false;
}
if (ereg('Password:',$data)) {
$cycle = true;
$ssh->write($su."\n");
}
if (ereg('암호:',$data)) {
$cycle = true;
$ssh->write($su."\n");
}
}
$ssh->write(" \n");
$cycle = true;
$result="";
while ($cycle) {
$data = $ssh->read();
echo $data;
if (ereg('\]$',$data)) {
// $cycle = false;
}
if (ereg('\]#',$data)) {
$cycle = false;
}
if (ereg('Password:',$data)) {
$cycle = true;
$ssh->write($su."\n");
}
if (ereg('암호:',$data)) {
$cycle = true;
$ssh->write($su."\n");
}
}
//각 서버에 test폴더 만들기
$comm=null;
$comm[]="mkdir -p /home/test \n";
for($c=0;$c<sizeof($comm);$c++)
{
$ssh->write($comm[$c]);
$cycle = true;
$result="";
while ($cycle) {
$data = $ssh->read();
echo $data;
if (ereg('\]$',$data)) {
$cycle = false;
}
if (ereg('\]#',$data)) {
$cycle = false;
}
if (ereg('yes',$data)) {
$cycle = true;
//sleep(1);
$ssh->write("Yes\n");
}
if (ereg('password:',$data)) {
$cycle = true;
$ssh->write("계정패스워드\n");
}
if (ereg('암호:',$data)) {
$cycle = true;
$ssh->write("계정패스워드\n");
}
}
$ssh->write(" \n");
$cycle = true;
$result="";
while ($cycle) {
$data = $ssh->read();
echo $data;
if (ereg('\]$',$data)) {
$cycle = false;
}
if (ereg('\]#',$data)) {
$cycle = false;
}
if (ereg('yes',$data)) {
$cycle = true;
//sleep(1);
$ssh->write("Yes\n");
}
if (ereg('password:',$data)) {
$cycle = true;
$ssh->write("계정패스워드\n");
}
if (ereg('암호:',$data)) {
$cycle = true;
$ssh->write("계정패스워드\n");
}
}
}
$ssh->disconnect();
continue;
}
catch (SSHException $e)
{
echo "에구 이서버는 잘안돼네여~";
echo "\n";
$fail_ip[]=$ip;
}
}
var_dump($fail_ip);
?><div class='small'>[이 게시물은 관리자님에 의해 2011-10-31 17:32:05 Linux에서 이동 됨]</div>
요거는 ssh2 는 지원안됍니당 ~
실행파일은 php로 작업의도에 맞게 응용하시면 됩니다 아래는 기본샘플입니당~
<?
require_once ('test_db.php'); //디비 커넥션
require_once ('ssh_in_php.php');
$db = new TestDB;
$cmd=null;
set_time_limit(0);
$qry = "select * from ip_table"; //루프돌리는 방법은 개인스탈에 따라~
$db->query($qry);
while($db->next_record())
{
try
{
$host = 아이피;
$port = 포트번호;
$user = 계정아이디;
$password = 계정패스워드;
$su = 루트패스워드;
$ssh = null;
$ssh = new SSH_in_PHP($host,$port);
$ssh->connect($user,$password);
$ssh->write("su -\n\n");
$cycle = true;
$result="";
while ($cycle) {
$data = $ssh->read();
echo $data;
if (ereg('\]$',$data)) {
// $cycle = false;
}
if (ereg('\]#',$data)) {
$cycle = false;
}
if (ereg('Password:',$data)) {
$cycle = true;
$ssh->write($su."\n");
}
if (ereg('암호:',$data)) {
$cycle = true;
$ssh->write($su."\n");
}
}
$ssh->write(" \n");
$cycle = true;
$result="";
while ($cycle) {
$data = $ssh->read();
echo $data;
if (ereg('\]$',$data)) {
// $cycle = false;
}
if (ereg('\]#',$data)) {
$cycle = false;
}
if (ereg('Password:',$data)) {
$cycle = true;
$ssh->write($su."\n");
}
if (ereg('암호:',$data)) {
$cycle = true;
$ssh->write($su."\n");
}
}
//각 서버에 test폴더 만들기
$comm=null;
$comm[]="mkdir -p /home/test \n";
for($c=0;$c<sizeof($comm);$c++)
{
$ssh->write($comm[$c]);
$cycle = true;
$result="";
while ($cycle) {
$data = $ssh->read();
echo $data;
if (ereg('\]$',$data)) {
$cycle = false;
}
if (ereg('\]#',$data)) {
$cycle = false;
}
if (ereg('yes',$data)) {
$cycle = true;
//sleep(1);
$ssh->write("Yes\n");
}
if (ereg('password:',$data)) {
$cycle = true;
$ssh->write("계정패스워드\n");
}
if (ereg('암호:',$data)) {
$cycle = true;
$ssh->write("계정패스워드\n");
}
}
$ssh->write(" \n");
$cycle = true;
$result="";
while ($cycle) {
$data = $ssh->read();
echo $data;
if (ereg('\]$',$data)) {
$cycle = false;
}
if (ereg('\]#',$data)) {
$cycle = false;
}
if (ereg('yes',$data)) {
$cycle = true;
//sleep(1);
$ssh->write("Yes\n");
}
if (ereg('password:',$data)) {
$cycle = true;
$ssh->write("계정패스워드\n");
}
if (ereg('암호:',$data)) {
$cycle = true;
$ssh->write("계정패스워드\n");
}
}
}
$ssh->disconnect();
continue;
}
catch (SSHException $e)
{
echo "에구 이서버는 잘안돼네여~";
echo "\n";
$fail_ip[]=$ip;
}
}
var_dump($fail_ip);
?><div class='small'>[이 게시물은 관리자님에 의해 2011-10-31 17:32:05 Linux에서 이동 됨]</div>
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 7830 | 10년 전 | 467 | ||
| 7829 |
|
10년 전 | 649 | |
| 7828 | 10년 전 | 577 | ||
| 7827 | 10년 전 | 479 | ||
| 7826 | 10년 전 | 500 | ||
| 7825 | 10년 전 | 534 | ||
| 7824 | 10년 전 | 490 | ||
| 7823 | 10년 전 | 433 | ||
| 7822 | 10년 전 | 406 | ||
| 7821 | 10년 전 | 355 | ||
| 7820 | 10년 전 | 371 | ||
| 7819 |
|
10년 전 | 772 | |
| 7818 | 10년 전 | 433 | ||
| 7817 | 10년 전 | 609 | ||
| 7816 | 10년 전 | 449 | ||
| 7815 | 10년 전 | 646 | ||
| 7814 | 10년 전 | 482 | ||
| 7813 | 10년 전 | 434 | ||
| 7812 | 10년 전 | 445 | ||
| 7811 | 10년 전 | 423 | ||
| 7810 | 10년 전 | 628 | ||
| 7809 | 10년 전 | 557 | ||
| 7808 | 10년 전 | 439 | ||
| 7807 | 10년 전 | 449 | ||
| 7806 |
프로그래머7
|
10년 전 | 1367 | |
| 7805 | 10년 전 | 1311 | ||
| 7804 |
zahir1312
|
10년 전 | 808 | |
| 7803 |
|
10년 전 | 1412 | |
| 7802 | 10년 전 | 512 | ||
| 7801 | 10년 전 | 886 | ||
| 7800 | 10년 전 | 1112 | ||
| 7799 | 10년 전 | 595 | ||
| 7798 | 10년 전 | 542 | ||
| 7797 | 10년 전 | 564 | ||
| 7796 | 10년 전 | 401 | ||
| 7795 | 10년 전 | 551 | ||
| 7794 | 10년 전 | 594 | ||
| 7793 | 10년 전 | 1095 | ||
| 7792 | 10년 전 | 520 | ||
| 7791 | 10년 전 | 613 | ||
| 7790 | 10년 전 | 539 | ||
| 7789 |
fbastore
|
10년 전 | 1492 | |
| 7788 | 10년 전 | 596 | ||
| 7787 | 10년 전 | 454 | ||
| 7786 | 10년 전 | 662 | ||
| 7785 | 10년 전 | 634 | ||
| 7784 | 10년 전 | 696 | ||
| 7783 | 10년 전 | 515 | ||
| 7782 | 10년 전 | 541 | ||
| 7781 | 10년 전 | 941 | ||
| 7780 | 10년 전 | 850 | ||
| 7779 | 10년 전 | 801 | ||
| 7778 | 10년 전 | 395 | ||
| 7777 | 10년 전 | 507 | ||
| 7776 | 10년 전 | 502 | ||
| 7775 | 10년 전 | 437 | ||
| 7774 | 10년 전 | 649 | ||
| 7773 | 10년 전 | 407 | ||
| 7772 | 10년 전 | 782 | ||
| 7771 | 10년 전 | 438 | ||
| 7770 | 10년 전 | 675 | ||
| 7769 | 10년 전 | 435 | ||
| 7768 | 10년 전 | 656 | ||
| 7767 | 10년 전 | 1212 | ||
| 7766 | 10년 전 | 540 | ||
| 7765 | 10년 전 | 601 | ||
| 7764 |
잘살아보자
|
10년 전 | 456 | |
| 7763 |
|
10년 전 | 1507 | |
| 7762 |
Tosea
|
10년 전 | 1092 | |
| 7761 | 10년 전 | 698 | ||
| 7760 |
잘살아보자
|
10년 전 | 772 | |
| 7759 |
잘살아보자
|
10년 전 | 613 | |
| 7758 |
잘살아보자
|
10년 전 | 667 | |
| 7757 | 10년 전 | 1300 | ||
| 7756 |
ITBANK
|
10년 전 | 1298 | |
| 7755 | 10년 전 | 1946 | ||
| 7754 | 10년 전 | 1106 | ||
| 7753 | 10년 전 | 925 | ||
| 7752 | 10년 전 | 1428 | ||
| 7751 |
잘살아보자
|
10년 전 | 582 | |
| 7750 |
잘살아보자
|
10년 전 | 512 | |
| 7749 |
잘살아보자
|
10년 전 | 544 | |
| 7748 |
잘살아보자
|
10년 전 | 566 | |
| 7747 |
잘살아보자
|
10년 전 | 643 | |
| 7746 |
잘살아보자
|
10년 전 | 706 | |
| 7745 |
잘살아보자
|
10년 전 | 951 | |
| 7744 |
잘살아보자
|
10년 전 | 443 | |
| 7743 | 10년 전 | 976 | ||
| 7742 |
starbros
|
10년 전 | 869 | |
| 7741 |
잘살아보자
|
10년 전 | 712 | |
| 7740 |
잘살아보자
|
10년 전 | 601 | |
| 7739 |
잘살아보자
|
10년 전 | 488 | |
| 7738 |
잘살아보자
|
10년 전 | 568 | |
| 7737 |
잘살아보자
|
10년 전 | 547 | |
| 7736 |
잘살아보자
|
10년 전 | 567 | |
| 7735 |
잘살아보자
|
10년 전 | 901 | |
| 7734 |
잘살아보자
|
10년 전 | 456 | |
| 7733 |
잘살아보자
|
10년 전 | 567 | |
| 7732 |
잘살아보자
|
10년 전 | 733 | |
| 7731 |
잘살아보자
|
10년 전 | 658 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기