많은 서버를 관리할때 일일이 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>
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 3530 | 14년 전 | 913 | ||
| 3529 | 14년 전 | 1132 | ||
| 3528 |
|
14년 전 | 1339 | |
| 3527 | 14년 전 | 1188 | ||
| 3526 |
|
14년 전 | 890 | |
| 3525 | 14년 전 | 1181 | ||
| 3524 | 14년 전 | 1401 | ||
| 3523 | 14년 전 | 1371 | ||
| 3522 | 14년 전 | 920 | ||
| 3521 | 14년 전 | 2096 | ||
| 3520 |
|
14년 전 | 435 | |
| 3519 | 14년 전 | 1055 | ||
| 3518 | 14년 전 | 903 | ||
| 3517 |
다케미카코
|
14년 전 | 749 | |
| 3516 |
|
14년 전 | 1239 | |
| 3515 |
NS미디어
|
14년 전 | 1676 | |
| 3514 | 14년 전 | 1032 | ||
| 3513 |
FreeZone
|
14년 전 | 821 | |
| 3512 |
|
14년 전 | 824 | |
| 3511 | 14년 전 | 1085 | ||
| 3510 | 14년 전 | 1380 | ||
| 3509 | 14년 전 | 1477 | ||
| 3508 | 14년 전 | 548 | ||
| 3507 | 14년 전 | 1095 | ||
| 3506 |
|
14년 전 | 988 | |
| 3505 | 14년 전 | 1008 | ||
| 3504 | 14년 전 | 1732 | ||
| 3503 |
letsgolee
|
14년 전 | 1496 | |
| 3502 | 14년 전 | 1379 | ||
| 3501 | 14년 전 | 1137 | ||
| 3500 | 14년 전 | 1151 | ||
| 3499 | 14년 전 | 1763 | ||
| 3498 |
리눅스초보100
|
14년 전 | 796 | |
| 3497 |
네비플러스
|
14년 전 | 578 | |
| 3496 |
도와주세요
|
14년 전 | 840 | |
| 3495 | 14년 전 | 819 | ||
| 3494 | 14년 전 | 1318 | ||
| 3493 | 14년 전 | 1578 | ||
| 3492 | 14년 전 | 1335 | ||
| 3491 | 14년 전 | 949 | ||
| 3490 | 14년 전 | 1019 | ||
| 3489 | 14년 전 | 1104 | ||
| 3488 | 14년 전 | 2844 | ||
| 3487 |
JMoon
|
14년 전 | 1030 | |
| 3486 | 14년 전 | 1693 | ||
| 3485 | 14년 전 | 1310 | ||
| 3484 | 14년 전 | 952 | ||
| 3483 | 14년 전 | 2239 | ||
| 3482 |
photolate
|
14년 전 | 2658 | |
| 3481 | 14년 전 | 765 | ||
| 3480 | 14년 전 | 1004 | ||
| 3479 | 14년 전 | 1888 | ||
| 3478 |
|
14년 전 | 2275 | |
| 3477 | 14년 전 | 1337 | ||
| 3476 | 14년 전 | 1473 | ||
| 3475 | 14년 전 | 810 | ||
| 3474 | 14년 전 | 1122 | ||
| 3473 | 14년 전 | 1121 | ||
| 3472 | 14년 전 | 1883 | ||
| 3471 | 14년 전 | 1147 | ||
| 3470 | 14년 전 | 821 | ||
| 3469 | 14년 전 | 917 | ||
| 3468 | 14년 전 | 222 | ||
| 3467 | 14년 전 | 967 | ||
| 3466 | 14년 전 | 877 | ||
| 3465 | 14년 전 | 893 | ||
| 3464 |
스카이워커
|
14년 전 | 1430 | |
| 3463 | 14년 전 | 2310 | ||
| 3462 | 14년 전 | 1363 | ||
| 3461 | 14년 전 | 1140 | ||
| 3460 |
New악마
|
14년 전 | 1520 | |
| 3459 | 14년 전 | 772 | ||
| 3458 | 14년 전 | 775 | ||
| 3457 | 14년 전 | 1031 | ||
| 3456 | 14년 전 | 1260 | ||
| 3455 | 14년 전 | 891 | ||
| 3454 | 14년 전 | 1178 | ||
| 3453 | 14년 전 | 1807 | ||
| 3452 | 14년 전 | 788 | ||
| 3451 | 14년 전 | 1119 | ||
| 3450 | 14년 전 | 1141 | ||
| 3449 | 14년 전 | 845 | ||
| 3448 | 14년 전 | 857 | ||
| 3447 | 14년 전 | 1243 | ||
| 3446 | 14년 전 | 1728 | ||
| 3445 | 14년 전 | 1630 | ||
| 3444 | 14년 전 | 1539 | ||
| 3443 |
|
14년 전 | 920 | |
| 3442 | 14년 전 | 1108 | ||
| 3441 | 14년 전 | 942 | ||
| 3440 |
바인플러스
|
14년 전 | 826 | |
| 3439 | 14년 전 | 2020 | ||
| 3438 | 14년 전 | 1289 | ||
| 3437 |
New악마
|
14년 전 | 1230 | |
| 3436 |
카프카07
|
14년 전 | 1294 | |
| 3435 |
|
14년 전 | 1521 | |
| 3434 |
|
14년 전 | 880 | |
| 3433 | 14년 전 | 1657 | ||
| 3432 | 14년 전 | 3946 | ||
| 3431 | 14년 전 | 1884 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기