2012년 6월 30일 토요일

[LiNuX] 라즈베리 파이 SSH 연결




1. 우선 사항
    1-1. 라즈베리 파이 에 데비안(Debian) 올리기
    1-2. 라즈베리 파이 최초 부팅



2. ssh 데몬을 시작 시키기 위해 root 권한을 획득 한다.

    모든 데몬의 시작/정지/재시작은  root 권한으로 실행 가능 하다.

    pi@raspberrypi:~$ sudo su

    root@raspberrypi:/home/pi# whoami
    root


3. ssh 데몬 시작

    ssh 데몬이 시작 되어 있지 않기 때문에 수동으로 시작 시켜 주어야 한다.

     root@raspberrypi:/home/pi# /etc/init.d/ssh start
     Starting OpenBSD Secure Shell server : sshd.
     root@raspberrypi:/home/pi#


4. 라즈베리 파이의 IP 주소 확인

     ifconfig 명령을 이용 하여 유선랜의 IP 주소를 알아 낸다.

     root@raspberrypi:/home/pi# ifconfig eth0
     eth0           Link encap:Ethernet  HWaddr b8:27:eb:04:6f:5d
                      inet addr:192.168.0.8  Bcast:192.168.0.255  Mask:255.255.255.0
                      UP BROADCAST RUNNING MULTICAST  MTU:1488  Metric:1
                      RX packets:3730 errors:0 dropped:0 overruns:0 frame:0
                      TX packets:873 errors:0 dropped:0 overruns:0 carrier:0
                      collisions:0 txqueuelen:1000
                      RX bytes:208246 (203.3 KiB)  TX bytes:88344 (86.2 KiB)

     root@raspberrypi:/home/pi#


5. 외부에서 SSH 연결 확인
   
    본인의 경우 내부 네트워크의 다른 컴퓨터에서 putty 나 Xshell 등의 ssh 클라이언트
    를 이용하여 라즈베리 파이의 IP 주소로 접속을 하였다.

     참고 : 최초 부팅후 별다른 설정을 하지 않았다면, iptables 가 올라가 있지 않은 상태.


6. SSH 데몬 자동 시작을 위한 chkconfig 패키지 설치

    데비안 리눅스의 경우 기본적으로 패키지 관리자를 apt-get 을 사용 한다.


    root@raspberrypi:/home/pi# apt-cache search chkconfig
    chkconfig - system tool to enable or disable system services

    root@raspberrypi:/home/pi# apt-get install chkconfig
    Reading package lists... Done
    Building dependency tree    
    Reading state information... Done
    The following NEW packages will be installed:
      chkconfig
    0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
    Need to get 9,182 B of archives.
    After this operation, 69.6 kB of additional disk space will be used.
    Get:1 http://ftp.uk.debian.org/debian/ squeeze/main chkconfig all 11.0-79.1-2 [9,182 B]
    Fetched 9,182 B in 1s (5,276 B/s)
    Selecting previously deselected package chkconfig.
    (Reading database ... 46441 files and directories currently installed.)
    Unpacking chkconfig (from .../chkconfig_11.0-79.1-2_all.deb) ...
    Processing triggers for man-db ...
    Setting up chkconfig (11.0-79.1-2) ...
    root@raspberrypi:/home/pi#


7. ssh 데몬 부팅시 활성화 

    현재 ssh의 동작 런레벨 확인

    root@raspberrypi:/home/pi# chkconfig --list | grep -i "ssh"
    ssh                       0:off  1:off  2:off  3:off  4:off  5:off  6:off
    root@raspberrypi:/home/pi#

    ssh 데몬이 모든 런레벨에서 off 상태다. 본인의 경우 ssh 데몬은 telnet 보다 안전
    하여 선호 하는 편이라 런레벨 2, 3, 5 에서 사용 할 수 있도록 설정을 한다.


    root@raspberrypi:/home/pi# chkconfig ssh -level 235 on


    root@raspberrypi:/home/pi# chkconfig --list | grep -i ssh
    ssh                       0:off  1:off  2:on   3:on   4:on   5:on   6:off 

    * 이상하게 런레벨4 에서도 on 으로 설정이 된다. 명령어 옵션을 찾아 봐야 할 듯.


    재부팅 하여, 자동으로 ssh 데몬이 시작 되는지 와 원격에서 ssh 로 연결이 되는지
    확인 하도록 한다.




댓글 없음 :

댓글 쓰기