많은 서버를 관리할때 일일이 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>
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 3830 | 14년 전 | 929 | ||
| 3829 | 14년 전 | 1676 | ||
| 3828 | 14년 전 | 954 | ||
| 3827 |
방황하는중년
|
14년 전 | 903 | |
| 3826 |
|
14년 전 | 1638 | |
| 3825 | 14년 전 | 874 | ||
| 3824 | 14년 전 | 722 | ||
| 3823 | 14년 전 | 735 | ||
| 3822 |
level999
|
14년 전 | 830 | |
| 3821 | 14년 전 | 1015 | ||
| 3820 |
TzM위드컴
|
14년 전 | 935 | |
| 3819 | 14년 전 | 988 | ||
| 3818 |
base64
|
14년 전 | 1097 | |
| 3817 |
base64
|
14년 전 | 962 | |
| 3816 | 14년 전 | 2237 | ||
| 3815 | 14년 전 | 1865 | ||
| 3814 |
|
14년 전 | 2535 | |
| 3813 | 14년 전 | 502 | ||
| 3812 | 14년 전 | 808 | ||
| 3811 | 14년 전 | 1066 | ||
| 3810 | 14년 전 | 670 | ||
| 3809 |
스님꼬신수녀
|
14년 전 | 651 | |
| 3808 | 14년 전 | 1455 | ||
| 3807 | 14년 전 | 1265 | ||
| 3806 | 14년 전 | 2369 | ||
| 3805 | 14년 전 | 1262 | ||
| 3804 | 14년 전 | 850 | ||
| 3803 | 14년 전 | 3369 | ||
| 3802 | 14년 전 | 1591 | ||
| 3801 | 14년 전 | 1005 | ||
| 3800 | 14년 전 | 1357 | ||
| 3799 | 14년 전 | 716 | ||
| 3798 |
커피는막심
|
14년 전 | 1840 | |
| 3797 | 14년 전 | 772 | ||
| 3796 | 14년 전 | 1206 | ||
| 3795 | 14년 전 | 711 | ||
| 3794 |
방황하는중년
|
14년 전 | 1244 | |
| 3793 | 14년 전 | 1479 | ||
| 3792 | 14년 전 | 993 | ||
| 3791 | 14년 전 | 782 | ||
| 3790 | 14년 전 | 1004 | ||
| 3789 | 14년 전 | 931 | ||
| 3788 | 14년 전 | 1950 | ||
| 3787 | 14년 전 | 1113 | ||
| 3786 | 14년 전 | 814 | ||
| 3785 | 14년 전 | 710 | ||
| 3784 | 14년 전 | 1321 | ||
| 3783 | 14년 전 | 2616 | ||
| 3782 | 14년 전 | 705 | ||
| 3781 |
|
14년 전 | 2538 | |
| 3780 |
헬프데스크
|
14년 전 | 1658 | |
| 3779 |
방황하는중년
|
14년 전 | 896 | |
| 3778 |
|
14년 전 | 1098 | |
| 3777 |
|
14년 전 | 1004 | |
| 3776 |
스누피사랑
|
14년 전 | 987 | |
| 3775 |
silver31
|
14년 전 | 500 | |
| 3774 |
|
14년 전 | 714 | |
| 3773 | 14년 전 | 811 | ||
| 3772 |
|
14년 전 | 1174 | |
| 3771 | 14년 전 | 871 | ||
| 3770 | 14년 전 | 1227 | ||
| 3769 | 14년 전 | 1010 | ||
| 3768 |
Dokjin
|
14년 전 | 1111 | |
| 3767 |
Dokjin
|
14년 전 | 713 | |
| 3766 | 14년 전 | 1023 | ||
| 3765 |
|
14년 전 | 919 | |
| 3764 | 14년 전 | 800 | ||
| 3763 | 14년 전 | 689 | ||
| 3762 | 14년 전 | 1171 | ||
| 3761 |
쉽다zzz
|
14년 전 | 1581 | |
| 3760 |
gtm100
|
14년 전 | 935 | |
| 3759 |
원시인교주
|
14년 전 | 778 | |
| 3758 | 14년 전 | 3316 | ||
| 3757 | 14년 전 | 841 | ||
| 3756 | 14년 전 | 730 | ||
| 3755 | 14년 전 | 2125 | ||
| 3754 | 14년 전 | 1511 | ||
| 3753 | 14년 전 | 2025 | ||
| 3752 | 14년 전 | 592 | ||
| 3751 | 14년 전 | 853 | ||
| 3750 |
방황하는중년
|
14년 전 | 713 | |
| 3749 |
hopeone
|
14년 전 | 544 | |
| 3748 | 14년 전 | 633 | ||
| 3747 | 14년 전 | 750 | ||
| 3746 | 14년 전 | 1501 | ||
| 3745 | 14년 전 | 868 | ||
| 3744 | 14년 전 | 908 | ||
| 3743 | 14년 전 | 535 | ||
| 3742 | 14년 전 | 1069 | ||
| 3741 | 14년 전 | 1659 | ||
| 3740 |
매너천사12
|
14년 전 | 1047 | |
| 3739 |
SGFlash
|
14년 전 | 1380 | |
| 3738 |
C2HGroup
|
14년 전 | 901 | |
| 3737 | 14년 전 | 1039 | ||
| 3736 | 14년 전 | 789 | ||
| 3735 | 14년 전 | 1110 | ||
| 3734 | 14년 전 | 1003 | ||
| 3733 | 14년 전 | 417 | ||
| 3732 | 14년 전 | 557 | ||
| 3731 | 14년 전 | 637 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기