많은 서버를 관리할때 일일이 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>
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 8230 | 9년 전 | 50 | ||
| 8229 | 9년 전 | 52 | ||
| 8228 |
커네드커네드
|
9년 전 | 98 | |
| 8227 | 9년 전 | 108 | ||
| 8226 | 9년 전 | 145 | ||
| 8225 | 9년 전 | 134 | ||
| 8224 | 9년 전 | 131 | ||
| 8223 | 9년 전 | 90 | ||
| 8222 |
|
9년 전 | 162 | |
| 8221 | 9년 전 | 77 | ||
| 8220 | 9년 전 | 75 | ||
| 8219 | 9년 전 | 80 | ||
| 8218 | 9년 전 | 111 | ||
| 8217 |
star3840
|
9년 전 | 98 | |
| 8216 | 9년 전 | 135 | ||
| 8215 | 9년 전 | 89 | ||
| 8214 | 9년 전 | 206 | ||
| 8213 | 9년 전 | 142 | ||
| 8212 | 9년 전 | 56 | ||
| 8211 | 9년 전 | 222 | ||
| 8210 | 9년 전 | 218 | ||
| 8209 | 9년 전 | 318 | ||
| 8208 | 9년 전 | 187 | ||
| 8207 | 9년 전 | 200 | ||
| 8206 |
|
9년 전 | 162 | |
| 8205 | 9년 전 | 147 | ||
| 8204 | 9년 전 | 110 | ||
| 8203 | 9년 전 | 203 | ||
| 8202 | 9년 전 | 126 | ||
| 8201 | 9년 전 | 166 | ||
| 8200 | 9년 전 | 135 | ||
| 8199 | 9년 전 | 186 | ||
| 8198 | 9년 전 | 155 | ||
| 8197 | 9년 전 | 135 | ||
| 8196 | 9년 전 | 517 | ||
| 8195 | 9년 전 | 133 | ||
| 8194 | 9년 전 | 268 | ||
| 8193 | 9년 전 | 135 | ||
| 8192 | 9년 전 | 163 | ||
| 8191 | 9년 전 | 115 | ||
| 8190 | 9년 전 | 111 | ||
| 8189 | 9년 전 | 165 | ||
| 8188 | 9년 전 | 112 | ||
| 8187 | 9년 전 | 121 | ||
| 8186 | 9년 전 | 130 | ||
| 8185 | 9년 전 | 291 | ||
| 8184 | 9년 전 | 86 | ||
| 8183 | 9년 전 | 308 | ||
| 8182 | 9년 전 | 138 | ||
| 8181 | 9년 전 | 114 | ||
| 8180 | 9년 전 | 678 | ||
| 8179 | 9년 전 | 474 | ||
| 8178 | 9년 전 | 278 | ||
| 8177 |
kiplayer
|
9년 전 | 286 | |
| 8176 | 9년 전 | 329 | ||
| 8175 | 9년 전 | 203 | ||
| 8174 | 9년 전 | 210 | ||
| 8173 | 9년 전 | 324 | ||
| 8172 | 9년 전 | 166 | ||
| 8171 | 9년 전 | 159 | ||
| 8170 | 9년 전 | 278 | ||
| 8169 |
커네드커네드
|
9년 전 | 243 | |
| 8168 | 9년 전 | 297 | ||
| 8167 | 9년 전 | 305 | ||
| 8166 | 9년 전 | 218 | ||
| 8165 | 9년 전 | 148 | ||
| 8164 | 9년 전 | 279 | ||
| 8163 | 9년 전 | 265 | ||
| 8162 | 9년 전 | 273 | ||
| 8161 | 9년 전 | 271 | ||
| 8160 |
|
9년 전 | 467 | |
| 8159 | 9년 전 | 386 | ||
| 8158 | 9년 전 | 204 | ||
| 8157 | 9년 전 | 341 | ||
| 8156 | 9년 전 | 256 | ||
| 8155 | 9년 전 | 231 | ||
| 8154 |
00년생용띠
|
9년 전 | 577 | |
| 8153 | 9년 전 | 206 | ||
| 8152 |
|
9년 전 | 385 | |
| 8151 | 9년 전 | 386 | ||
| 8150 | 9년 전 | 477 | ||
| 8149 |
Jangfolk
|
9년 전 | 314 | |
| 8148 | 9년 전 | 148 | ||
| 8147 | 9년 전 | 357 | ||
| 8146 | 9년 전 | 410 | ||
| 8145 | 9년 전 | 344 | ||
| 8144 | 9년 전 | 309 | ||
| 8143 | 9년 전 | 165 | ||
| 8142 | 9년 전 | 411 | ||
| 8141 | 9년 전 | 357 | ||
| 8140 | 9년 전 | 908 | ||
| 8139 | 9년 전 | 231 | ||
| 8138 |
전갈자리남자
|
9년 전 | 376 | |
| 8137 | 9년 전 | 357 | ||
| 8136 | 9년 전 | 717 | ||
| 8135 |
|
9년 전 | 769 | |
| 8134 |
PlayPixel
|
9년 전 | 481 | |
| 8133 |
|
9년 전 | 420 | |
| 8132 | 9년 전 | 431 | ||
| 8131 | 9년 전 | 787 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기