linux class(new) 1 페이지

본문 바로가기
사이트 내 전체검색


회원로그인

linux class(new)

ftp 서비스 - client

페이지 정보

작성자 admin 작성일16-02-23 18:30 조회845회 댓글0건

본문

ftp 서비스
- file transfer protocol을 의미하며 호스트간에 file 송수신을 하기 위한 프로토콜 및 서비스를 의미한다.
- 송수신 모드는 아스키모드와 바이너리 모드 두가지 형식이 있다.

GUI 환경에서의 ftp client 전용 프로그램으로는 알ftp , 파일질라 등이 있다.

command line 에서 ftp client 사용법.
*. ftp 서비스 테스트를 위해서
centos(server1) 에서는 ftp 서버 실행 및 방화벽 설정해제, 테스트할 계정을 생성한다.

useradd fuser1
centos[/root]# passwd fuser1
fuser1 사용자의 비밀 번호 변경 중
새 암호:
잘못된 암호: 너무 짧습니다
잘못된 암호: 너무 간단함
새 암호 재입력:
passwd: 모든 인증 토큰이 성공적으로 업데이트 되었습니다.

- 테스트 할 계정 생성

centos[/root]# pgrep -fl vsftpd
centos[/root]# service vsftpd start
vsftpd에 대한 vsftpd을 시작 중: [ OK ]
centos[/root]# pgrep -fl vsftpd
4123 /usr/sbin/vsftpd /etc/vsftpd/vsftpd.conf
centos[/root]# iptables -F

- ftp 서비스 실행 및 방화벽 설정 해제.

centos2(server2)에서는 일반계정으로 ftp 서버로 접속하도록 한다.

centos2[user1 /home/user1]$ ftp
ftp> help
Commands may be abbreviated. Commands are:

! debug mdir sendport site
$ dir mget put size
account disconnect mkdir pwd status
append exit mls quit struct
ascii form mode quote system
bell get modtime recv sunique
binary glob mput reget tenex
bye hash newer rstatus tick
case help nmap rhelp trace
cd idle nlist rename type
cdup image ntrans reset user
chmod lcd open restart umask
close ls prompt rmdir verbose
cr macdef passive runique ?
delete mdelete proxy send
ftp>
ftp> help lcd
lcd change local working directory
ftp>


-- ftp 주요 명령어
*.명령은 줄여쓸수 있다.

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



ftp> open centos
Connected to centos (172.20.1.100).
220 (vsFTPd 2.2.2)
Name (centos:user1): fuser
331 Please specify the password.
Password:
530 Login incorrect.
Login failed.
ftp> user
(username) fuser1
331 Please specify the password.
Password:
230 Login successful.
ftp> pwd
257 "/home/fuser1"


만약 서버에 selinux 가 사용중이면 일반계정으로 login 이 제대로 안될수 있다.
그런경우에는 selinux 설정을 확인하고 ftp 서비스 관련 설정을 해야 한다.

centos[/root]# sestatus
SELinux status: enabled
SELinuxfs mount: /selinux
Current mode: enforcing
Mode from config file: enforcing
Policy version: 24
Policy from config file: targeted
centos[/root]# getsebool -a | grep ftp
allow_ftpd_anon_write --> off
allow_ftpd_full_access --> off
allow_ftpd_use_cifs --> off
allow_ftpd_use_nfs --> off
ftp_home_dir --> on <----------- 만약 off 로 되어 있으면 on 으로 변경
ftpd_connect_db --> off
ftpd_use_fusefs --> off
ftpd_use_passive_mode --> off
httpd_enable_ftp_server --> off
tftp_anon_write --> off
tftp_use_cifs --> off
tftp_use_nfs --> off
centos[/root]# setsebool -P ftp_home_dir on <-- 시간이 좀 걸린다.(대략 1분이하로)


- 파일 전송
1. 파일 다운로드

ftp> cd /etc
250 Directory successfully changed.
ftp> ls issue*
227 Entering Passive Mode (172,20,1,100,181,188).
150 Here comes the directory listing.
-rw-r--r-- 1 0 0 47 Nov 27 2013 issue
-rw-r--r-- 1 0 0 46 Nov 27 2013 issue.net
226 Directory send OK.
ftp> pwd
257 "/etc"
ftp> ! pwd <--- '!'(느낌표)가 명령어 앞에 있으면 shell command 이며 local 에서 실행된다.
/home/user1 <--- local 의 현재경로
ftp> ! mkdir download <--- local 의 현재디렉토리에 다운로드 디렉토리 생성
ftp> lcd download <--- local 디렉토리 이동
Local directory now /home/user1/download
ftp> ! pwd
/home/user1/download
ftp> ascii <--- 전송 모드를 아스키 모드로 전환(디폴트는 바이너리 모드)
200 Switching to ASCII mode.
ftp> get issue* <--- get 은 '*' 문자를 사용할 수 없다.
227 Entering Passive Mode (172,20,1,100,57,10).
550 Failed to open file. <--- 다운로드 실패
ftp> mget issue* <--- mget 은 한번에 여러개의 파일을 전송할수 있으며 '*' 문자 사용가능.
mget issue? y <--- 대화식으로 실행
227 Entering Passive Mode (172,20,1,100,79,143).
150 Opening BINARY mode data connection for issue (47 bytes). <-- 바이너리 모드로 연결됨
WARNING! 3 bare linefeeds received in ASCII mode <--- 경고 메시지는 ftp 서버가 현재 아스키모드
전송을 허용하지 않아서 보여주는것.
File may not have transferred correctly. <--- 전송모드가 지켜지지 않아서 출력된 메시지.
226 Transfer complete. <--- 전송 완료.
46 bytes received in 0.0233 secs (1.97 Kbytes/sec)
ftp>


- 만약 비대화식 모드 및 전송 할때 해시마크를 찍어서 전송상태를 표시하고 싶으면 아래처럼
하면 된다.

ftp> cd /bin
250 Directory successfully changed.
ftp> hash
Hash mark printing on (1024 bytes/hash mark).
ftp> prompt
Interactive mode off.
ftp> mget cp mkdir
local: cp remote: cp
227 Entering Passive Mode (172,20,1,100,63,85).
150 Opening BINARY mode data connection for cp (122872 bytes).
##############################################################################################################
WARNING! 382 bare linefeeds received in ASCII mode
File may not have transferred correctly.
226 Transfer complete.
122872 bytes received in 0.00501 secs (24525.35 Kbytes/sec)
local: mkdir remote: mkdir
227 Entering Passive Mode (172,20,1,100,71,92).
150 Opening BINARY mode data connection for mkdir (49384 bytes).
##############################################
WARNING! 146 bare linefeeds received in ASCII mode
File may not have transferred correctly.
226 Transfer complete.
49384 bytes received in 0.00209 secs (23594.84 Kbytes/sec)
ftp> ! ls
cp issue issue.net mkdir services
ftp>


-- upload 도 명령어만 다르고 같은 방법으로 하면된다.
*. get 에 대응되는 upload 명령은 put
mget 에 대응되는 upload 명령은 mput
-------------------------------------------------------------------------------------
실습.
- 현재 접속된 ftpuser1 계정으로 ftp 서버의 /tmp 디렉토리로 이동하여
/tmp/upload 디렉토리를 하나 생성후 client 의 /bin/a*, /bin/b*, /bin/c* 파일 업로드하기.


ftp 서버에 익명계정(anonymous) 접속 방법.
(*. 탐색기나 웹브라우저에서는 --> ftp://ftp서버주소)


centos2[user1 /home/user1]$ ftp centos
Connected to centos (172.20.1.100).
220 (vsFTPd 2.2.2)
Name (centos:user1): anonymous
331 Please specify the password.
Password: <---- 그냥 엔터(anonymous 계정은 암호가 없음)
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> pwd
257 "/"
ftp> ls
227 Entering Passive Mode (172,20,1,100,99,148).
150 Here comes the directory listing.
drwxr-xr-x 2 0 0 4096 Jul 24 2015 pub
226 Directory send OK.
ftp> cd /etc
550 Failed to change directory. <--- 보안상 익명계정은 접속한 익명계정 디렉토리이외에
다른 디렉토리로 이동할수 없다.
ftp> quit
221 Goodbye.

댓글목록

등록된 댓글이 없습니다.


접속자집계

오늘
72
어제
75
최대
611
전체
448,122
개인정보취급방침 서비스이용약관 twoseven.kr All rights reserved.
상단으로