본문 바로가기

공부/리눅스

ftp 서비스 - client

반응형
ftp 서비스

- file transfer protocol을 의미하며 호스트간에 file 송수신을 하기 위한 프로토콜 및 서비스를 의미한다.
- 송수신 하는 파일은 이진형식과 바이너리 형식 두가지 형식이 있다.

ftp client

[root@star tmp]# ftp
ftp> ?  <= ftp prompt 에서 ? 를 입력하면 command 목록을 볼수 있다.

Commands may be abbreviated.  Commands are:

!              cr              mdir            proxy          send
$              delete          mget            sendport        site
account        debug          mkdir          put            size
append          dir            mls            pwd            status
ascii          disconnect      mode            quit            struct
bell            form            modtime        quote          system
binary          get            mput            recv            sunique
bye            glob            newer          reget          tenex
case            hash            nmap            rstatus        trace
ccc            help            nlist          rhelp          type
cd              idle            ntrans          rename          user
cdup            image          open            reset          umask
chmod          lcd            passive        restart        verbose
clear          ls              private        rmdir          ?
close          macdef          prompt          runique
cprotect        mdelete        protect        safe
ftp> help bin  <= 각 명령어에 대한 간단한 설명을 보려면 'help 명령어' 하면 된다.
binary          set binary transfer type
ftp>

이중에서 자주 사용되는 명령은

*.명령은 줄여쓸수 있다.

! : ftp 프롬프트에서 셀명령어를 쓸수 있다.
ascii : 전송모드를 ascii 타입으로 지정
bin(binary) : 전송모드를 binary 모드로 지정 => 아스키 파일을 송수신 하는 경우가 아니면 전송모드는
                                                                      전부 바이너리 모드로 해야 한다.
get : 하나의 파일을 다운로드
mget : 여러개의 파일을 다운로드
cd : 디렉토리 변경
mkdir : 디렉토리 생성
rmdir : 디렉토리 삭제
hash : 파일송수신시 '#' 마크를 찍어서 전송상태 표시해준다.
close : 접속 끊기
quit: ftp 를 끝내고 shell 로 돌아간다.
user : 로그인시 id 나 암호가 틀렸을때 다시 입력하는 명령어
lcd : 서버가 아닌 클라이언트의 현재 디렉토리를 변경하는 명령어
ex) lcd /tmp => 클라이언트의 현재 작업경로를 /tmp 로 변경.



ex) internic 에서 named.root(= named.ca) 파일을 다운로드 받는과정이다.


[root@star tmp]# ftp ftp.rs.internic.net
Connected to ftp.rs.internic.net.
220-**********************************************************
220-*****                                                *****
220-***** InterNIC Public FTP Server                    *****
220-*****                                                *****
220-***** Login with username "anonymous"                *****
220-***** You may change directories to the following:  *****
220-*****                                                *****
220-*****  domain  -  Root Domain Zone Files            *****
220-*****                                                *****
220-***** Unauthorized access to this system may        *****
220-***** result in criminal prosecution.                *****
220-*****                                                *****
220-***** All sessions established with this server are  *****
220-***** monitored and logged. Disconnect now if you do *****
220-***** not consent to having your actions monitored  *****
220-***** and logged.                                    *****
220-*****                                                *****
220-**********************************************************
220
530 Please login with USER and PASS.
530 Please login with USER and PASS.
KERBEROS_V4 rejected as an authentication type
Name (ftp.rs.internic.net:root): anonymous  <= 익명계정으로 접속한다.
331 Please specify the password.  <= 익명계정은 패스워드를 마음대로 쳐도 인증이 된다.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> dir
227 Entering Passive Mode (198,41,0,6,43,115)
150 Here comes the directory listing.
drwxr-xr-x    2 ftp      ftp          4096 Oct 06 19:03 domain
226 Directory send OK.
ftp> cd domain
250 Directory successfully changed.
ftp> dir  <= 파일리스트를 출력하는 ftp 명령어
227 Entering Passive Mode (198,41,0,6,100,241)
150 Here comes the directory listing.
-rw-r--r--    1 ftp      ftp          457 Oct 06 19:03 INTERNIC_ROOT_ZONE.signatures
-rw-r--r--    1 ftp      ftp          693 Oct 06 19:03 INTERNIC_ROOT_ZONE.signatures.asc
-rw-r--r--    1 ftp      ftp          687 Oct 06 17:51 arpa.zone.gz
-rw-r--r--    1 ftp      ftp            33 Oct 06 17:51 arpa.zone.gz.md5
-rw-r--r--    1 ftp      ftp            65 Oct 06 17:51 arpa.zone.gz.sig
-rw-r--r--    1 ftp      ftp          2876 Feb 04  2008 db.cache
-rw-r--r--    1 ftp      ftp            43 Feb 04  2008 db.cache.md5
-rw-r--r--    1 ftp      ftp            72 Feb 04  2008 db.cache.sig
-rw-r--r--    1 ftp      ftp          2879 Feb 04  2008 named.cache
-rw-r--r--    1 ftp      ftp            46 Feb 04  2008 named.cache.md5
-rw-r--r--    1 ftp      ftp            72 Feb 04  2008 named.cache.sig
-rw-r--r--    1 ftp      ftp          2878 Feb 04  2008 named.root
-rw-r--r--    1 ftp      ftp            45 Feb 04  2008 named.root.md5
-rw-r--r--    1 ftp      ftp            72 Feb 04  2008 named.root.sig
-rw-r--r--    1 ftp      ftp        19903 Oct 06 19:03 root.zone.gz
-rw-r--r--    1 ftp      ftp            33 Oct 06 19:03 root.zone.gz.md5
-rw-r--r--    1 ftp      ftp            65 Oct 06 19:03 root.zone.gz.sig
226 Directory send OK.
ftp> ascii  <= 전송모드를 선택하는 명령어(여기서는 ascil 모드로 전송받겠다는 것이다.)
200 Switching to ASCII mode.
ftp> hash  <= 1024 바이트당 해시마크('#')을 찍어서 전송상황을 출력하겠다는 의미.
Hash mark printing on (1024 bytes/hash mark).
ftp> get named.root  => get 은 한개의 파일을 다운받아오는 명령어 (참고 : get named* <= 이렇게 할수는 없다. 와일드카드 문자를 쓰려면
                                                                                                              여러개의 파일을 동시 다운로드 받을수 있는 met 명령을 써야 한다)
local: named.root remote: named.root
227 Entering Passive Mode (198,41,0,6,170,61)
150 Opening BINARY mode data connection for named.root (2878 bytes).
WARNING! 85 bare linefeeds received in ASCII mode              ==> 여기서 경고 메시지가 떴네요. 이 파일은 아스키 파일이므로 ascii 모드로 받는게 맞는데
File may not have transferred correctly.                                        이상합니다. 경고가 떳으므로 다운로드 받은 파일이 제대로 동작할지 다소 불확실합니다.
226 File send OK.
2878 bytes received in 0.00053 seconds (5.3e+03 Kbytes/s)
ftp> bin                                                  => 아스키 모드일때 경고메시지가 출력하였으므로 전송타입을 binary 모드로 바꿨다.
200 Switching to Binary mode.
ftp> get named.root
local: named.root remote: named.root
227 Entering Passive Mode (198,41,0,6,60,184)
150 Opening BINARY mode data connection for named.root (2878 bytes).
##
226 File send OK.
2878 bytes received in 0.00017 seconds (1.6e+04 Kbytes/s)
ftp> close
ftp> quit
[root@star tmp]# ls -l named.root
-rw-r--r--  1 root root 2878  8월 16 11:16 named.root
[root@star tmp]# file named.root
named.root: ASCII English text

=> 제대로 받아졌습니다.

반응형