The Pursuit of Happyness

반응형
패키지 설치
rpm -ivh [패키지 파일 이름]

설치된 패키지 확인
rpm -qa

패키지 업그레이드
rpm -Uvh [패키지 파일 이름]

패키지 삭제
rpm -ev [패키지 파일 이름]

반응형

반응형
이 포스트는 아래 링크에 있는 자료를 요약한 자료 입니다.

http://www.thegeekstuff.com/2008/11/3-steps-to-perform-ssh-login-without-password-using-ssh-keygen-ssh-copy-id/ 



ssh-keygen 과 ssh-copy-id 를 이용하면  패스워드를 입력하지 않고 리눅스 서버에 접속할수 있습니다.

ssh-keygen 은 public / private 키를 생성하는 명령어이고,

ssh-copy-id 는 로컬 호스트에 있는 public 키를 원격 서버에 있는 인증된 키를 저장하는 파일 (authorized_keys)  에 추가해 주는 명령어 입니다.

ssh-copy-id 는 원격 호스트의 홈 폴더에 있는 ~/.ssh 폴더, ~/.ssh/ authorized_keys 파일에 적절한 권한을 부여해줍니다.


1 단계 로컬호스트에서 ssh-key-gen 을 이용하여 public / private 키를 생성하기

userid@local-host$ [Note: You are on local-host here]

userid@local-host$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/home/userid/.ssh/id_rsa):[Enter key]
Enter passphrase (empty for no passphrase): [Press enter key]
Enter same passphrase again: [Pess enter key]
Your identification has been saved in /home/userid/.ssh/id_rsa.
Your public key has been saved in /home/userid/.ssh/id_rsa.pub.
The key fingerprint is:
73:b4:ee:aa:b5:c5:d8:e1:f1:a5:1e:26:5f:2f:53:9f userid@local-host

2 단계 ssh-copy-id 를 이용해서 원격 서버로 public 키를 복사하기

userid@local-host$ ssh-copy-id -i ~/.ssh/id_rsa.pub remote-host
userid@remote-host's password:
Now try logging into the machine, with "ssh 'remote-host'", and check in:

.ssh/authorized_keys

to make sure we haven't added extra keys that you weren't expecting.
Note: ssh-copy-id 는 원격 서버에 있는 .ssh/authorized_key 에 public 키를 추가해 주는 작업입니다.


3단계 패스워드없이 원격서버에 로그인하기

userid@local-host$ ssh remote-host
Last login: Sun Nov 16 17:22:33 2008 from 192.168.1.2
[Note: SSH did not ask for password.]

userid@remote-host$ [Note: You are on remote-host here]

정리를 해 보면 서버1에서 서버2에 접속하기 위해서는 서버1에서 공용키를 생성해서 서버2에 복사해서 인증을 해 두어야 한다는 것입니다.

맥에서는 ssh-copy-id 라는 명령어가 없기 때문에 ssh-copy-id 에 해당하는 부분은 수동으로 설정을 해야 합니다.

방법은 서버1에서 ssh-keygen 으로 생성한 ~/.ssh/id_rsa.pub 파일을 서버2로 보냅니다. 

scp ~/.ssh/id_rsa.pub remote-host:home/userid

서버2에 로그인 하여, 다음의 명령어를 이용하여 public 키를 추가합니다.

cat ~/id_rsa.pub >> ~/.ssh/authorized_key



반응형

반응형
서비스 목록 보기
chkconfig --list

부팅시 서비스가 자동으로 실행되게 하기
chkconfig [서비스명] on

부팅시 서비스가 자동으로 실행되지 않게 하기
chkconfig [서비스명] off

ex)
chkconfig httpd on
chkconfig httpd off

참고로 부팅 레벨에 따라서 서비스 실행여부를 자세히 설정할 수도 있다.



 
반응형

반응형

sudo dmidecode --type 17

관련 링크
http://www.cyberciti.biz/faq/check-ram-speed-linux/  

dmidecode 가 설치되어 있지 않은 경우는 아래 명령을 이용하여 설치할 수 있다.

yum install dmidecode 

 
반응형

반응형
<?php

function post_request($url, $data) {
// Convert the data array into URL Parameters like a=b&foo=bar etc.
$data = http_build_query($data);

// parse the given URL
$url = parse_url($url);

if ($url['scheme'] != 'http') {
return "Error:Only HTTP request are supported!";
}

// extract host and path:
$host = $url['host'];
$path = $url['path'];
$res = '';

// open a socket connection on port 80 - timeout: 300 sec
if ($fp = fsockopen($host, 80, $errno, $errstr, 300)) {
$reqBody = $data;
$reqHeader = "POST $path HTTP/1.1\r\n" . "Host: $host\r\n";
$reqHeader .= "Content-type: application/x-www-form-urlencoded\r\n"
. "Content-length: " . strlen($reqBody) . "\r\n"
. "Connection: close\r\n\r\n";

/* send request */
fwrite($fp, $reqHeader);
fwrite($fp, $reqBody);

while(!feof($fp)) {
$res .= fgets($fp, 1024);
}

fclose($fp);
} else {
return "Error:Cannot Connect!";
}

// split the result header from the content
$result = explode("\r\n\r\n", $res, 2);

$header = isset($result[0]) ? $result[0] : '';
$content = isset($result[1]) ? $result[1] : '';

return $content;
}

// usage
$url =  "http://www.example.com/receiver.php";
$data = array("key" => "value");
$res = post_request($url, $value);

?> 
 
반응형

반응형
구글코드에 있는 소스

http://code.google.com/p/php-excel-reader/


반응형

반응형

$text = preg_replace("/\\\\/", "/", $text);
반응형

반응형
먼저 .svn 폴더가 있는지를 확인하는 방법
>> find . -type d -name .svn 

다음의 명령어를 통해 모든  .svn 폴더를 삭제할 수 있음
>> find . -type d -name .svn | xargs rm -rf




 
반응형

반응형
strtotime 에서 2100년이 넘어갈때 제대로 처리하지 못하는 것은 다음의 코드를 응용해서 해결할수 있다.

function dateCompare($dt1, $dt2)
{
        $y1 = substr($dt1, 0, 4);
        $y2 = substr($dt2, 0, 4);

        if ($y1 > $y2) return -1;
        else if ($y1 < $y2) return 1;

        $startPos = 2;
        for($i=0;$i<5;$i++)
        {
                $startPos += 3;
                $v1 = substr($dt1, $startPos, 2);
                $v2 = substr($dt2, $startPos, 2);

                if ($v1 > $v2) return -1;
                else if ($v1 < $v2) return 1;
        }

        return 0;
}

function addYears($dt, $year)
{
        $yr = substr($dt, 0, 4);
        return ($yr + $year) . substr($dt, 4);
}

반응형

반응형
<?php
        foreach($_POST as $key => $value)
        {
                print $key . ":" . $value . "<br>";
        }
?>
반응형