'리눅스 초급/FTP'에 해당되는 글 5건

  1. 2016.05.02 [FTP](5) Passive mode와 Active mode
  2. 2016.05.02 [FTP](4) FTP와 FileZilla 사용하기
  3. 2016.04.28 [FTP](3) FTP 설치 및 설정
  4. 2016.04.28 [FTP](2) FTP 기본명령어
  5. 2016.04.28 [FTP](1) FTP의 이해

1. ACTIVE mode

 

전통적으로 21번 port를 server ftp port로 알고 있습니다.

이는 command를 위한 port이고

실제 data를 전송하기 위해서는 data전송을 위한 port를 사용합니다.

보통 data전송 port는 20번 port를 사용합니다.

 

클라이언트는 1024번 이상의 빈 port를 골라서 command port로 사용하고

해당포트에 +1을 더한 port를 data port로 사용합니다.

 

예를 들어)

1. 클라이언트가 서버 ftp에 접속하려고 1080번 port를 이용하여 서버 ftp에

   접속 요청을 날립니다. 이때 +1더한 1081번 port의 정보를 같이 서버에 보냅니다.

2. 서버 ftp의 21번 포트에서 해당 클라이언트의 요청을 수락하고 21번 command port는

   1080번과 20번 data port는 1081번과 connection을 맺습니다.

3. 클라이언트에서 데이터를 요청하면

   서버측에서 클라이언트로 해당 데이터를 넣어줍니다.

 

 

2. PASSIVE mode

 

passive mode 일때 서버의 command port는 21번이며

data port는 1024번 이상의 사용하지 않는 port 중 하나를 사용합니다.

 

클라이언트는 1024번 이상의 빈 port를 골라서 command port로 사용하고

해당포트에 +1을 더한 port를 data port로 사용합니다.

 

예를 들어)

1. 클라이언트가 서버 ftp에 접속하려고 1080번 port를 이용하여 서버 ftp에

   접속 요청을 날립니다. 이때 +1더한 1081번 port의 정보를 같이 서버에 보냅니다.

2. 서버 ftp의 21번 port에서 해당 클라이언트의 요청을 수락하고 21번 command port는

   1080번과 connection을 이루며

   서버측의 1024이상의 빈 port와 클라이언트의 1081번 port와 connection을 맺습니다.

3. 클라이언트에서 데이터를 요청하고

   클라이언트가 서버에서 데이터를 가져옵니다.

 

'리눅스 초급 > FTP' 카테고리의 다른 글

[FTP](4) FTP와 FileZilla 사용하기  (0) 2016.05.02
[FTP](3) FTP 설치 및 설정  (0) 2016.04.28
[FTP](2) FTP 기본명령어  (0) 2016.04.28
[FTP](1) FTP의 이해  (0) 2016.04.28
Posted by 알 수 없는 사용자
,

1. 먼저 ftp 로컬로 접속이 가능한지 테스트를 하는 도중에 login fail이 떴다.


[root@localhost vsftpd]# ftp

ftp> open

(to) 220.116.179.196

Connected to 220.116.179.196 (220.116.179.196).

220 (vsFTPd 2.2.2)

Name (220.116.179.196:root): root

331 Please specify the password.

Password:

500 OOPS: cannot change directory:/root

Login failed.



2. setsebool 명령어를 이용하여 ftpd full access on 을 설정해준다.

[root@localhost vsftpd]# setsebool allow_ftpd_full_access on

[root@localhost vsftpd]# getsebool -a | grep ftp
allow_ftpd_anon_write --> off
allow_ftpd_full_access --> on
allow_ftpd_use_cifs --> off

ftp> open
(to) 220.116.179.196
Connected to 220.116.179.196 (220.116.179.196).
220 (vsFTPd 2.2.2)
Name (220.116.179.196:root): root
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.

* setsebool 명령어란?
NAME
       setsebool - set SELinux boolean value

SYNOPSIS
       setsebool [ -PV] boolean value | bool1=val1 bool2=val2 ...

DESCRIPTION
       setsebool  sets  the current state of a particular SELinux boolean or a
       list of booleans to a given value. The value may be 1 or true or on  to
       enable the boolean, or 0 or false or off to disable it.

구글링해도 애매하게 나오길래 man page를 검색해보았다. setsebool 는 현재 상태를 설정해주는 특정 selinux의 boolean 이나 boolean 리스트이다. 1은 사용가능, 0은 사용불가능이다. selinux 정책으로 사용되는 기능들을 setsebool을 통하여 끄고 킬 수 있는 명령어이다.


3. FileZilla로 파일 업로드하기

[root@localhost centos]# ls -l

합계 5617564

-rw-r--r--. 1 root root 4467982336 2016-05-02 20:40 CentOS-6.5-x86_64-bin-DVD1.iso

-rw-r--r--. 1 root root 1284395008 2016-05-02 20:35 CentOS-6.5-x86_64-bin-DVD2.iso


윈도우에 있는 이미지 파일들이 /centos 안으로 잘들어갔다


성공!




'리눅스 초급 > FTP' 카테고리의 다른 글

[FTP](5) Passive mode와 Active mode  (0) 2016.05.02
[FTP](3) FTP 설치 및 설정  (0) 2016.04.28
[FTP](2) FTP 기본명령어  (0) 2016.04.28
[FTP](1) FTP의 이해  (0) 2016.04.28
Posted by 알 수 없는 사용자
,

1. vsFTP 설치

[root@vilinux-03 ~]# yum -y install vsftpd

-> yum 명령으로 간단하게 vsftpd 설치가 가능하다.

[root@vilinux-03 ~]# rpm -qa | grep ftp
ftp-0.17-54.el6.x86_64
vsftpd-2.2.2-14.el6_7.1.x86_64
-> vsftp가 잘 설치된 것을 볼 수 있다.


2. /etc/vsftp/vsftpd.conf 설정하기

anonymous_enable=NO 

-> 익명의 사용자가 접속할 수 있는지 설정한다. 기본값은 YES로 보안을 위해 NO로 바꿔준다.

local_enable=YES

-> local 사용자가 사용가능한지 설정해준다.

write_enable=YES

-> 접속한 사용자가 write할 수 있는지 설정한다.

local_umask=022

-> 파일을 업로드하거나 받았을 때 기본 umask값

anon_upload_enable=YES
-> 위의 anonymous_enable 과 연관된 설정으로 익명의 사용자가 업로드 할 수 있게 할 것인지 설정한다.

dirmessage_enable=YES
-> 사용자가 특정 디렉토리에 접근하였을 때 메시지를 보여준다.

xferlog_enable=YES
-> vsftp의 로그파일로 오류가 있거나 작업을 하였을 때 확인할 수 있다.

xferlog_file=/var/log/xferlog
-> vsftp의 로그파일 경로

connect_from_port_20=YES
-> ftp는 20,21번 포트를 사용한다.

chroot_local_user=YES
-> local 사용자가 접근했을 때 chroot으로 상위 디렉토리에 접근하지 못하게 막는다. 즉 계정의 홈디렉토리를 최상위로 설정하여 상위 디렉토리에 접근 할 수 없다. 

listen=YES
-> ftp 요청을 받기 위한 설정



3. vsftp 잘 작동하는지 확인

 3-1. 실습을 위해서 방화벽을 꺼준다.(실습을 위해 그냥 다꺼버리는게 속편합니다)

[root@vilinux-03 /]# service iptables stop

iptables: Setting chains to policy ACCEPT: filter          [  OK  ]

iptables: Flushing firewall rules:                         [  OK  ]

iptables: Unloading modules:                               [  OK  ]



 3-2. selinux도 꺼준다.(selinux enabled 안바꿨다가 동작하지 않았던 경험이..)

[root@vilinux-03 /]# cat /etc/sysconfig/selinux | grep disabled

#     disabled - No SELinux policy is loaded.

SELINUX=disabled

[root@vilinux-03 /]# cat /etc/selinux/config | grep disabled

#     disabled - No SELinux policy is loaded.

SELINUX=disabled



 3-3. 실습하기 위해 yong 유저를 만들고 test! 파일을 생성해준다.
[root@vilinux-03 /]# cd /home/yong
[root@vilinux-03 yong]# ls
test!

 

 3-4. 01번 클라이언트로 접속했을 때 test! 파일이 보이는 것을 확인할 수 있다.
[root@vilinux-01 ~]# ftp
ftp> open
(to) 14.0.81.236
Connected to 14.0.81.236 (14.0.81.236).
220 (vsFTPd 2.2.2)
Name (14.0.81.236:root): yong
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> pwd
257 "/home/yong"
ftp> ls
227 Entering Passive Mode (14,0,81,236,126,245).
150 Here comes the directory listing.
-rw-r--r--    1 0        0               0 Apr 28 02:38 test!
226 Directory send OK.

*실습을 위해 vsftpd.conf 에서 chroot_local_user=NO로 바꿨습니다. 


 3-5. 550 Failed to change directory 오류

ftp> cd /home/yong

550 Failed to change directory.


해결

chroot_local_user=NO


여기서 중요한 문제가 발생한다. chroot 항목을 NO로 풀어버리면 다른 사용자가 상위 디렉토리를 활보하고 다니게 된다. 보안상 굉장히 위험하다.


 3-6. chroot 응용법

다른 사용자는 막아두고 yong만 상위 디렉토리를 이용하게 하고 싶다면 chroot_list 에 yong 을 적어놓고 아래와 같이 설정합니다.

chroot_local_user=YES

chroot_list_enable=YES


[root@vilinux-03 yong]# cat /etc/vsftpd/chroot_list
#root 
yong

[root@vilinux-01 ~]# ftp
ftp> open
(to) 14.0.81.236
Connected to 14.0.81.236 (14.0.81.236).
220 (vsFTPd 2.2.2)
Name (14.0.81.236:root): yong
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> pwd
257 "/home/yong"
ftp> ls
227 Entering Passive Mode (14,0,81,236,44,106).
150 Here comes the directory listing.
-rw-r--r--    1 0        0               0 Apr 28 02:38 test!
226 Directory send OK.

[root@vilinux-01 ~]# ftp
ftp> open 14.0.81.236
Connected to 14.0.81.236 (14.0.81.236).
220 (vsFTPd 2.2.2)
Name (14.0.81.236:root): won
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> pw
257 "/"
ftp> cd /home/won
550 Failed to change directory.

chroot_list에 설정해둔  yong 사용자는 다른 디렉토리를 사용할 수 있고 list에 없는 won 사용자는 다른 디렉토리 이동이 안되는 것을 볼 수 있습니다.







* 다음 글에선 passvie mode와 active mode의 차이점을 알아보겠습니다!

'리눅스 초급 > FTP' 카테고리의 다른 글

[FTP](5) Passive mode와 Active mode  (0) 2016.05.02
[FTP](4) FTP와 FileZilla 사용하기  (0) 2016.05.02
[FTP](2) FTP 기본명령어  (0) 2016.04.28
[FTP](1) FTP의 이해  (0) 2016.04.28
Posted by 알 수 없는 사용자
,

1. FTP 명령어

open : 일반사용자가 ftp서버에 접속할 때 사용한다.

ex) open IP, hostname, domainname


close : 접속을 종료한다.

ex) close


ascii : ASCII 전송 모드로 바뀐다

ex) type acill


bin : 이진 모드로 바뀐다. 일반적으로 사용한다.

ex) type bin


get : 정확한 이름을 지정하여 파일을 받는다.

ex) get 파일명


mget : Multiple get 여러 개의 파일을 동시에 받는다

ex) mget 파일명


put : 정확한 이름으로 파일을 전송한다.

ex) put 파일명


mput : Multiple put 여러 개의 파일을 동시에 전송한다.

ex) mput 파일명


* 이 외의 pwd, ls, mkdir 등의 기본 명령어들도 똑같은 기능으로 사용이 가능하다.


'리눅스 초급 > FTP' 카테고리의 다른 글

[FTP](5) Passive mode와 Active mode  (0) 2016.05.02
[FTP](4) FTP와 FileZilla 사용하기  (0) 2016.05.02
[FTP](3) FTP 설치 및 설정  (0) 2016.04.28
[FTP](1) FTP의 이해  (0) 2016.04.28
Posted by 알 수 없는 사용자
,

1. FTP

 웹상에서 파일을 PC로 다운받거나 업로드 할 때에 사용하는 프로토콜이다. FTP는 서버와 클라이언트로 나눠진다. 

포트는 21번을 사용하며 자신에게 오는 FTP 클라이언트들의 요청을 받아 들일 준비를 하고 있는 프로토콜이다. 


2. FTP 의 종류

 2-1. SFTP

Secure FTP 즉 보안이 강화된 FTP라고 보면 된다. SSH을 통해서 파일을 전송하는 프로토콜이다.

 2-2. TFTP

Trivial FTP 로서 FTP, SFTP와는 다르게 UDP를 사용한다. UDP 는 전송 도중에 데이터가 유실될 가능성이 높다.

예전에는 장비들의 펌웨어 업그레이드를 위하여 TFTP가 자주 사용되었다.

 2-3. vsFTP

 vsftp는 보안 부분을 특히 강조한 데몬으로 Redhat, Suse, Open-BSD에서 기본 FTP로 채택하고 있으며 보안, 빠른 퍼포먼스, 안정성을 주요 특징으로 소개하고 있다. 

 2-4. proFTP

 Professional FTP Daemon 서버는 Unix 호환 운영체제를 위해 배포되고 있는 FTP 데몬으로 GPL에 의거하여 만들어진 프로그램이므로 누구나 자유롭게 수정, 배포, 사용할 수 있습니다.


3.  FTP 사용방법

 3-1. 웹브라우저를 사용하는 방법 

웹 주소는 http://~ 형식으로 시작하게 된다. http를 ftp로 바꿔서 ftp://~ 로 쓰게 되면 서버에 접속이 가능해진다.

 3-2. FTP 전용 클라이언트를 사용하는 방법

알FTP나 Filezilla 같은 프로그램으로 원하는 서버의 ip주소를 입력하여 서버에 접속할 수 있다.

 3-3. linux terminal 을 이용하는 방법

 terminal 창에 들어가서 ftp -> open 서버ip 를 통하여 접속할 수 있다.


 

'리눅스 초급 > FTP' 카테고리의 다른 글

[FTP](5) Passive mode와 Active mode  (0) 2016.05.02
[FTP](4) FTP와 FileZilla 사용하기  (0) 2016.05.02
[FTP](3) FTP 설치 및 설정  (0) 2016.04.28
[FTP](2) FTP 기본명령어  (0) 2016.04.28
Posted by 알 수 없는 사용자
,