많은 서버를 관리할때 일일이 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>
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 3430 | 14년 전 | 1985 | ||
| 3429 | 14년 전 | 1404 | ||
| 3428 |
카프카07
|
14년 전 | 1873 | |
| 3427 | 14년 전 | 1507 | ||
| 3426 | 14년 전 | 1335 | ||
| 3425 | 14년 전 | 1001 | ||
| 3424 | 14년 전 | 962 | ||
| 3423 | 14년 전 | 1179 | ||
| 3422 | 14년 전 | 1421 | ||
| 3421 | 14년 전 | 5946 | ||
| 3420 | 14년 전 | 1487 | ||
| 3419 | 14년 전 | 1201 | ||
| 3418 | 14년 전 | 1249 | ||
| 3417 | 14년 전 | 832 | ||
| 3416 | 14년 전 | 1014 | ||
| 3415 | 14년 전 | 1618 | ||
| 3414 |
elsarose
|
14년 전 | 1081 | |
| 3413 | 14년 전 | 742 | ||
| 3412 | 14년 전 | 1277 | ||
| 3411 | 14년 전 | 1346 | ||
| 3410 | 14년 전 | 1669 | ||
| 3409 | 14년 전 | 996 | ||
| 3408 | 14년 전 | 4572 | ||
| 3407 | 14년 전 | 1160 | ||
| 3406 | 14년 전 | 1131 | ||
| 3405 | 14년 전 | 1149 | ||
| 3404 | 14년 전 | 1350 | ||
| 3403 | 14년 전 | 1159 | ||
| 3402 |
네비플러스
|
14년 전 | 900 | |
| 3401 | 14년 전 | 975 | ||
| 3400 | 14년 전 | 1410 | ||
| 3399 | 14년 전 | 719 | ||
| 3398 | 14년 전 | 1291 | ||
| 3397 |
아이피마스터
|
14년 전 | 1281 | |
| 3396 | 14년 전 | 1366 | ||
| 3395 |
kimam
|
14년 전 | 4107 | |
| 3394 |
kimam
|
14년 전 | 1352 | |
| 3393 | 14년 전 | 1051 | ||
| 3392 | 14년 전 | 1476 | ||
| 3391 | 14년 전 | 1640 | ||
| 3390 |
|
14년 전 | 840 | |
| 3389 |
sooram
|
14년 전 | 2081 | |
| 3388 | 14년 전 | 2061 | ||
| 3387 | 14년 전 | 1645 | ||
| 3386 |
|
14년 전 | 1605 | |
| 3385 | 14년 전 | 1107 | ||
| 3384 | 14년 전 | 1599 | ||
| 3383 |
보헤미안7
|
14년 전 | 1533 | |
| 3382 | 14년 전 | 1236 | ||
| 3381 |
wldus
|
14년 전 | 966 | |
| 3380 |
wldus
|
14년 전 | 2709 | |
| 3379 | 14년 전 | 2028 | ||
| 3378 |
보헤미안7
|
14년 전 | 1388 | |
| 3377 | 14년 전 | 2039 | ||
| 3376 |
네비플러스
|
14년 전 | 914 | |
| 3375 | 14년 전 | 1020 | ||
| 3374 | 14년 전 | 1644 | ||
| 3373 | 14년 전 | 1750 | ||
| 3372 | 14년 전 | 1345 | ||
| 3371 |
호박둥구리
|
14년 전 | 1034 | |
| 3370 | 14년 전 | 1197 | ||
| 3369 |
열라바보숑
|
14년 전 | 1123 | |
| 3368 | 14년 전 | 1987 | ||
| 3367 | 14년 전 | 2115 | ||
| 3366 | 14년 전 | 1989 | ||
| 3365 | 14년 전 | 1120 | ||
| 3364 | 14년 전 | 1692 | ||
| 3363 | 14년 전 | 1748 | ||
| 3362 | 14년 전 | 1860 | ||
| 3361 |
|
14년 전 | 3634 | |
| 3360 |
호피무늬쫄티
|
14년 전 | 1181 | |
| 3359 |
|
14년 전 | 1968 | |
| 3358 |
DreamT
|
14년 전 | 894 | |
| 3357 | 14년 전 | 1021 | ||
| 3356 | 14년 전 | 859 | ||
| 3355 | 14년 전 | 1325 | ||
| 3354 |
sooram
|
14년 전 | 1779 | |
| 3353 | 14년 전 | 1316 | ||
| 3352 | 14년 전 | 1169 | ||
| 3351 | 14년 전 | 839 | ||
| 3350 | 14년 전 | 1814 | ||
| 3349 | 14년 전 | 1378 | ||
| 3348 | 14년 전 | 932 | ||
| 3347 | 14년 전 | 2317 | ||
| 3346 | 14년 전 | 1433 | ||
| 3345 | 14년 전 | 1356 | ||
| 3344 | 14년 전 | 888 | ||
| 3343 |
visualp
|
14년 전 | 1751 | |
| 3342 |
abetterday
|
14년 전 | 2727 | |
| 3341 |
|
14년 전 | 1225 | |
| 3340 |
|
14년 전 | 611 | |
| 3339 | 14년 전 | 2179 | ||
| 3338 |
|
14년 전 | 1949 | |
| 3337 | 14년 전 | 904 | ||
| 3336 | 14년 전 | 1478 | ||
| 3335 | 14년 전 | 1662 | ||
| 3334 | 14년 전 | 1515 | ||
| 3333 | 14년 전 | 886 | ||
| 3332 |
sooram
|
14년 전 | 844 | |
| 3331 | 14년 전 | 1142 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기