FTP Server 구축
Linux
  • 설치 OS는 RedHat Enterprise Linux 5
  • VSFTPD파일 버전은 3.0.2버전
[root@localhost ~]# ls
anaconda-ks.cfg       Desktop             sendmail.8.14.9.tar.gz  yum-2.0.7
bind-9.9.2-P2         install.log         vsftpd-3.0.2            yum-2.0.7.tar.gz
bind-9.9.2-P2.tar.gz  install.log.syslog  vsftpd-3.0.2.tar.gz
  • FTP를 사용할려면 vsftpd라는 파일이 필요한데
    여기서는 3.0.2버전을 가지고 설치를 해보겠다.
    위를 보면 vsftpd가 /root/home 디렉토리에 놓여져 있다
  • tar압축을 풀고, 압축이 풀린 디렉토리에 들어가자
[root@localhost ~]# cd vsftpd-3.0.2
[root@localhost vsftpd-3.0.2]#
[root@localhost vsftpd-3.0.2]#
[root@localhost vsftpd-3.0.2]# ls
access.c     filesize.h     ls.h              privops.h         secutil.h     sysutil.h
access.h     filestr.c      main.c            privsock.c        session.h     tcpwrap.c
ascii.c      filestr.h      Makefile          privsock.h        SIZE          tcpwrap.h
ascii.h      ftpcmdio.c     netstr.c          ptracesandbox.c   SPEED         TODO
AUDIT        ftpcmdio.h     netstr.h          ptracesandbox.h   ssl.c         tunables.c
banner.c     ftpcodes.h     oneprocess.c      README            ssl.h         tunables.h
banner.h     ftpdataio.c    oneprocess.h      README.security   sslslave.c    TUNING
BENCHMARKS   ftpdataio.h    opts.c            README.ssl        sslslave.h    twoprocess.c
BUGS         ftppolicy.c    opts.h            readwrite.c       standalone.c  twoprocess.h
builddefs.h  ftppolicy.h    parseconf.c       readwrite.h       standalone.h  utility.c
Changelog    hash.c         parseconf.h       RedHat            str.c         utility.h
COPYING      hash.h         port              REFS              str.h         vsf_findlibs.sh
COPYRIGHT    INSTALL        postlogin.c       REWARD            strlist.c     vsftpd.8
defs.h       ipaddrparse.c  postlogin.h       secbuf.c          strlist.h     vsftpd.conf
dummyinc     ipaddrparse.h  postprivparent.c  secbuf.h          sysdeputil.c  vsftpd.conf.5
EXAMPLE      LICENSE        postprivparent.h  seccompsandbox.c  sysdeputil.h  vsftpver.h
FAQ          logging.c      prelogin.c        seccompsandbox.h  sysstr.c      xinetd.d
features.c   logging.h      prelogin.h        SECURITY          sysstr.h
features.h   ls.c           privops.c         secutil.c         sysutil.c
[root@localhost vsftpd-3.0.2]#
  • 폴더를 만들어줘야 하는데 -p옵션으로 하위까지 전부 만들어버리자
  • 아래 명령어를 고대로 치면 된다.
[root@localhost vsftpd-3.0.2]#
[root@localhost vsftpd-3.0.2]# mkdir -p /usr/local/sbin /usr/local/man/man{5,8}
[root@localhost vsftpd-3.0.2]# mkdir /var/ftp
[root@localhost vsftpd-3.0.2]# chown root.root /var/ftp
[root@localhost vsftpd-3.0.2]# chmod og-w /var/ftp
[root@localhost vsftpd-3.0.2]#
  • 이제 디렉토리도 만들고 권한까지 다 줬으니 make && make install을 이용해서
    *디렉토리에 설치하면 된다.
[root@localhost vsftpd-3.0.2]# make
gcc -c main.c -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wall -W -Wshadow -Werror -Wformat-security -D_FORTIFY_SOURCE=2  -idirafter dummyinc
gcc -c utility.c -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wall -W -Wshadow -Werror -Wformat-security -D_FORTIFY_SOURCE=2  -idirafter dummyinc
gcc -c prelogin.c -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wall -W -Wshadow -Werror -Wformat-security -D_FORTIFY_SOURCE=2  -idirafter dummyinc
gcc -c ftpcmdio.c -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wall -W -Wshadow -Werror -Wformat-security -D_FORTIFY_SOURCE=2  -idirafter dummyinc
gcc -c postlogin.c -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wall -W -Wshadow -Werror -Wformat-security -D_FORTIFY_SOURCE=2  -idirafter dummyinc
gcc -c privsock.c -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wall -W -Wshadow -Werror -Wformat-security -D_FORTIFY_SOURCE=2  -idirafter dummyinc
gcc -c tunables.c -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wall -W -Wshadow -Werror -Wformat-security -D_FORTIFY_SOURCE=2  -idirafter dummyinc
gcc -c ftpdataio.c -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wall -W -Wshadow -Werror -Wformat-security -D_FORTIFY_SOURCE=2  -idirafter dummyinc
gcc -c secbuf.c -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wall -W -Wshadow -Werror -Wformat-security -D_FORTIFY_SOURCE=2  -idirafter dummyinc
gcc -c ls.c -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wall -W -Wshadow -Werror -Wformat-security -D_FORTIFY_SOURCE=2  -idirafter dummyinc
gcc -c postprivparent.c -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wall -W -Wshadow -Werror -Wformat-security -D_FORTIFY_SOURCE=2  -idirafter dummyinc
gcc -c logging.c -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wall -W -Wshadow -Werror -Wformat-security -D_FORTIFY_SOURCE=2  -idirafter dummyinc
gcc -c str.c -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wall -W -Wshadow -Werror -Wformat-security -D_FORTIFY_SOURCE=2  -idirafter dummyinc
gcc -c netstr.c -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wall -W -Wshadow -Werror -Wformat-security -D_FORTIFY_SOURCE=2  -idirafter dummyinc
gcc -c sysstr.c -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wall -W -Wshadow -Werror -Wformat-security -D_FORTIFY_SOURCE=2  -idirafter dummyinc
gcc -c strlist.c -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wall -W -Wshadow -Werror -Wformat-security -D_FORTIFY_SOURCE=2  -idirafter dummyinc
gcc -c banner.c -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wall -W -Wshadow -Werror -Wformat-security -D_FORTIFY_SOURCE=2  -idirafter dummyinc
gcc -c filestr.c -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wall -W -Wshadow -Werror -Wformat-security -D_FORTIFY_SOURCE=2  -idirafter dummyinc
gcc -c parseconf.c -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wall -W -Wshadow -Werror -Wformat-security -D_FORTIFY_SOURCE=2  -idirafter dummyinc
gcc -c secutil.c -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wall -W -Wshadow -Werror -Wformat-security -D_FORTIFY_SOURCE=2  -idirafter dummyinc
gcc -c ascii.c -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wall -W -Wshadow -Werror -Wformat-security -D_FORTIFY_SOURCE=2  -idirafter dummyinc
gcc -c oneprocess.c -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wall -W -Wshadow -Werror -Wformat-security -D_FORTIFY_SOURCE=2  -idirafter dummyinc
gcc -c twoprocess.c -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wall -W -Wshadow -Werror -Wformat-security -D_FORTIFY_SOURCE=2  -idirafter dummyinc
gcc -c privops.c -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wall -W -Wshadow -Werror -Wformat-security -D_FORTIFY_SOURCE=2  -idirafter dummyinc
gcc -c standalone.c -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wall -W -Wshadow -Werror -Wformat-security -D_FORTIFY_SOURCE=2  -idirafter dummyinc
gcc -c hash.c -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wall -W -Wshadow -Werror -Wformat-security -D_FORTIFY_SOURCE=2  -idirafter dummyinc
gcc -c tcpwrap.c -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wall -W -Wshadow -Werror -Wformat-security -D_FORTIFY_SOURCE=2  -idirafter dummyinc
gcc -c ipaddrparse.c -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wall -W -Wshadow -Werror -Wformat-security -D_FORTIFY_SOURCE=2  -idirafter dummyinc
gcc -c access.c -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wall -W -Wshadow -Werror -Wformat-security -D_FORTIFY_SOURCE=2  -idirafter dummyinc
gcc -c features.c -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wall -W -Wshadow -Werror -Wformat-security -D_FORTIFY_SOURCE=2  -idirafter dummyinc
gcc -c readwrite.c -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wall -W -Wshadow -Werror -Wformat-security -D_FORTIFY_SOURCE=2  -idirafter dummyinc
gcc -c opts.c -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wall -W -Wshadow -Werror -Wformat-security -D_FORTIFY_SOURCE=2  -idirafter dummyinc
gcc -c ssl.c -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wall -W -Wshadow -Werror -Wformat-security -D_FORTIFY_SOURCE=2  -idirafter dummyinc
gcc -c sslslave.c -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wall -W -Wshadow -Werror -Wformat-security -D_FORTIFY_SOURCE=2  -idirafter dummyinc
gcc -c ptracesandbox.c -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wall -W -Wshadow -Werror -Wformat-security -D_FORTIFY_SOURCE=2  -idirafter dummyinc
gcc -c ftppolicy.c -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wall -W -Wshadow -Werror -Wformat-security -D_FORTIFY_SOURCE=2  -idirafter dummyinc
gcc -c sysutil.c -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wall -W -Wshadow -Werror -Wformat-security -D_FORTIFY_SOURCE=2  -idirafter dummyinc
gcc -c sysdeputil.c -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wall -W -Wshadow -Werror -Wformat-security -D_FORTIFY_SOURCE=2  -idirafter dummyinc
gcc -c seccompsandbox.c -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wall -W -Wshadow -Werror -Wformat-security -D_FORTIFY_SOURCE=2  -idirafter dummyinc
gcc -o vsftpd main.o utility.o prelogin.o ftpcmdio.o postlogin.o privsock.o tunables.o ftpdataio.o secbuf.o ls.o postprivparent.o logging.o str.o netstr.o sysstr.o strlist.o banner.o filestr.o parseconf.o secutil.o ascii.o oneprocess.o twoprocess.o privops.o standalone.o hash.o tcpwrap.o ipaddrparse.o access.o features.o readwrite.o opts.o ssl.o sslslave.o ptracesandbox.o ftppolicy.o sysutil.o sysdeputil.o seccompsandbox.o -Wl,-s -fPIE -pie -Wl,-z,relro -Wl,-z,now `./vsf_findlibs.sh`
  • 여기선 make와 make install을 한꺼번에 해줬다 (make && make install)
[root@localhost vsftpd-3.0.2]# make install
if [ -x /usr/local/sbin ]; then \
                install -m 755 vsftpd /usr/local/sbin/vsftpd; \
        else \
                install -m 755 vsftpd /usr/sbin/vsftpd; fi
if [ -x /usr/local/man ]; then \
                install -m 644 vsftpd.8 /usr/local/man/man8/vsftpd.8; \
                install -m 644 vsftpd.conf.5 /usr/local/man/man5/vsftpd.conf.5; \
        elif [ -x /usr/share/man ]; then \
                install -m 644 vsftpd.8 /usr/share/man/man8/vsftpd.8; \
                install -m 644 vsftpd.conf.5 /usr/share/man/man5/vsftpd.conf.5; \
        else \
                install -m 644 vsftpd.8 /usr/man/man8/vsftpd.8; \
                install -m 644 vsftpd.conf.5 /usr/man/man5/vsftpd.conf.5; fi
if [ -x /etc/xinetd.d ]; then \
                install -m 644 xinetd.d/vsftpd /etc/xinetd.d/vsftpd; fi
  • 그리고 주요 설정파일들을 etc안의 디렉토리에 복사한다.
[root@localhost vsftpd-3.0.2]# cp vsftpd.conf /etc/vsftpd.conf
[root@localhost vsftpd-3.0.2]# cp RedHat/vsftpd.pam /etc/pam.d/vsftpd
[root@localhost vsftpd-3.0.2]# cp RedHat/vsftpd.log /etc/logrotate.d/vsftpd

그리고 vsftpd.conf파일을 vi로 열고 아래와 같이 설정한다.

[root@localhost vsftpd-3.0.2]# vi /etc/vsftpd.conf
anonymous_enable=YES
local_enable=YES
write_enable=YES
local_umask=022
dirmessage_enable=YES
xferlog_enable=YES
connect_from_port_20=YES
xferlog_file=/var/log/vsftpd.log
listen=NO
pam_service_name=vsftpd      /이건 직접 맨 아래에 기재하면 된다.
  • 설정이 다 되었으면 데몬을 재실행시켜주면 된다.
  • 그리고 ftp localhost를 실행시켜서
  • name : root, password도 설정하면 끝난다.
[root@localhost vsftpd-3.0.2]# /etc/init.d/xinetd restart
Stopping xinetd:                                           [  OK  ]
Starting xinetd:                                           [  OK  ]
[root@localhost vsftpd-3.0.2]#
[root@localhost vsftpd-3.0.2]#
[root@localhost vsftpd-3.0.2]# ftp localhost
Connected to localhost.localdomain.
220 (vsFTPd 3.0.2)
530 Please login with USER and PASS.
530 Please login with USER and PASS.
KERBEROS_V4 rejected as an authentication type
Name (localhost:root): root
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> ls
227 Entering Passive Mode (127,0,0,1,203,36).
150 Here comes the directory listing.
drwxr-xr-x    2 0        0            4096 Aug 25 10:06 Desktop
-rw-------    1 0        0            1382 Aug 25 09:46 anaconda-ks.cfg
drwxrwxr-x   11 10292    9901         4096 Aug 25 10:41 bind-9.9.2-P2
-rw-r--r--    1 0        0         7277958 Aug 25 10:40 bind-9.9.2-P2.tar.gz
-rw-r--r--    1 0        0           41113 Aug 25 09:45 install.log
-rw-r--r--    1 0        0            3748 Aug 25 09:45 install.log.syslog
-rw-r--r--    1 0        0         2114293 Aug 25 10:40 sendmail.8.14.9.tar.gz
drwxr-x--x    8 1000     1000         4096 Aug 25 11:37 vsftpd-3.0.2
-rw-r--r--    1 0        0          192808 Aug 25 10:40 vsftpd-3.0.2.tar.gz
drwxrwxr-x    6 500      500          4096 Aug 25 10:08 yum-2.0.7
-rw-r--r--    1 0        0          174080 Aug 25 10:05 yum-2.0.7.tar.gz
226 Directory send OK.
ftp> bye
221 Goodbye.
  • bye를 통해서 빠져나올 수 있고
    이제 공유할 디렉토리를 만들고 그 안에 파일도 만들어 ftp에서 가능한지
    실행시켜 보면 된다.
  • 아래와 같이 ftp디렉토리로 이동해서 공유할 디렉토리를 하나 만들고
    그 안에 아무거나 만들어서 인터넷창에 ftp://(자신의 호스트ip)를 적어주면 끝
    그럼 알ftp나, 파일질라 등으로 실험해보자 (밑에 추가)
[root@localhost vsftpd-3.0.2]# cd /var/ftp
[root@localhost ftp]# mkdir byebye
[root@localhost ftp]# cd byebye
[root@localhost byebye]# vi goodbye.txt
[root@localhost byebye]#
[root@localhost byebye]# vi /etc/sysconfig/network /호스트네임변경 명령어
[root@localhost byebye]#
[root@localhost byebye]# chmod 777 /var/ftp /슈퍼유저 권한주기
[root@localhost byebye]#
Broadcast message from root (pts/1) (Mon Aug 25 21:02:10 2014):

The system is going down for reboot NOW!
  • 추가로 dns에 연동하고 싶다면 named.conf파일과 namedb디렉토레 안에 zone파일을생성해서 추가 해주면 가능하다.
  • 아래 /usr/local/dns/etc/named.conf열어서 아래 dbserver쪽 추가하시면 됩니다.
  • 저는 hostname이 dbserver라 dbserver라고 적어줬고 아래 file 이름,경로 잘 적어주셔야 합니다.

options {
           directory "/usr/local/dns/etc/namedb";
           dump-file "/usr/local/dns/etc/named_dump.db";
           statistics-file "/usr/local/dns/etc/tmp/named.stats";
           pid-file "/usr/local/dns/etc/run/named.pid";
};
zone "." IN{
         type hint;
         file "named.root";
};
zone "localhost" IN{
          type master;
          file "zone-localhost";
};
zone "0.0.127.in-addr.arpa " IN{
         type master;
         file "zone-0.0.127.in-addr.arpa";
};
zone "naver.com" IN{
          type master;
          file "zone-naver.com";
};
zone "dbserver.com" IN{
        type master;
        file "zone-dbserver.com";
};
  • 그리고 /usr/local/dns/etc/namedb/만들 존파일 생성 vi로 만들어서 아래처럼 적어주면 된다.
$TTL    3H
@       SOA     root. ( 2 1D 1H 1W 1H )
        IN      NS      @
        IN      A       192.168.24.143 /자신의 호스트ip

www     IN      A       192.168.24.143
ftp     IN      A       192.168.24.143
  • 끝이고 ftp://root@dbserver 적어주면 된다!

'Linux' 카테고리의 다른 글

linux,unix에 vi editor 구문강조  (0) 2014.10.31
make install 안될 때 해결법  (0) 2014.10.31
Mail Server 구축  (0) 2014.10.31
APM server 구축  (0) 2014.10.31
Linux의 네크워크 설정  (0) 2014.09.03