root@wl ~ # wget ftp://ftp.sunfreeware.com/pub/freeware/intel/10/tcp_wrappers-7.6-sol10-intel-local.gz root@wl ~ # gunzip tcp_wrappers-7.6-sol10-intel-local.gz root@wl ~ # pkgadd -d tcp_wrappers-7.6-sol10-intel-local
root@wl ~ # wget ftp://ftp.proftpd.org/distrib/source/proftpd-1.3.2a.tar.bz2
root@wl ~ # tar xvfj proftpd-1.3.2a.tar.bz2
root@wl ~ # cd proftpd-1.3.2a
root@wl ~/proftpd-1.3.2a # ./configure \
--with-includes=/usr/local/include:/usr/sfw/include:/usr/include:/usr/local/ssl/include:/usr/local/mysql/include/mysql \
--with-libraries=/usr/local/lib:/usr/sfw/lib:/usr/lib:/usr/local/lib:/usr/local/ssl/lib:/usr/local/mysql/lib/mysql \
--prefix=/usr/local/proftpd \
--enable-sendfile \
--enable-shadow \
--with-modules=mod_wrap:mod_tls:mod_sql:mod_sql_mysql 1)
root@wl ~/proftpd-1.3.2a # make
root@wl ~/proftpd-1.3.2a # make install
1) 모듈설명
root@wl # vi /etc/profile
# for ProFTPD located at /usr/local/proftpd
if [ -x /usr/local/proftpd/bin/ftpwho ]
then
PATH=/usr/local/proftpd/bin:$PATH; export PATH;
fi
root@wl #
root@wl ~ # vi /etc/inetd.conf #ftp ~~~ root@wl ~ # ps -ef | grep inetd root 150 1 0 10월 22 ? 0:00 /usr/sbin/inetd -s root@wl ~ # kill -HUP 150 root@wl ~ # vi /usr/local/proftpd/etc/proftpd.conf DefaultRoot ~ 1) root@wl ~ # /usr/local/proftpd/sbin/proftpd # 실행 root@wl ~ # pkill proftpd # 종료1) 다른건 몰라도 기본 루트 설정만큼은 언코멘트 해 놓는다.
root@wl ~ # vi /usr/local/proftpd/etc/proftpd.conf # 이 내용을 복사해서 사용할 때 # 뒷 부분은 삭제해야 한다. AllowstoreRestart on # Upload Resume 허용. 대부분의 서버는 off로 되어있다. 익숙한 ftp사용자가 아니면 off로 놓자. RequireValidShell off # 익명연결 허용 UseReverseDNS off # Reverse DNS 사용 안함 IdentLookups off # IP 룩업 사용 안함 ShowSymlinks on # 심볼릭 링크 보임 DefaultRoot ~ # 기본 루트 설정 ServerIdent on "FTP server" # 서버 정보 보임 DisplayConnect /etc/proftp.connect.msg # 로그인 이전 메시지 DisplayLogin /etc/proftp.login.msg # 로그인 이후 메시지 MaxClients 100 "Sorry, the maximum number(%m) of allowed users are already connected" # 최대 클라이언트 수 MaxClientsPerHost 5 "Sorry, the maximum number clients (%m) from your host are already connected" # 호스트당 최대 클라이언트 수 HideUser root # 사용자 숨김 HideGroup root # 그룹 숨김 AuthPAM On # PAM 인증 AuthPAMConfig ftp # PAM 설정 TCPAccessFiles /etc/hosts.allow /etc/hosts.deny # TCPWrapper <Directory /export/home/*> AllowstoreRestart on # Upload Resume을 가능하게 한다. </Directory> <IfModule mod_tls.c> TLSEngine on TLSLog TLSLog /var/log/ftps.log TLSProtocol TLSv1 # Are clients required to use FTP over TLS when talking to this server? TLSRequired off # Server's certificate TLSRSACertificateFile /usr/local/ssl/certs/signed-req.pem TLSRSACertificateKeyFile /usr/local/ssl/certs/req.key # CA the server trusts TLSCACertificateFile /usr/local/ssl/certs/ca.crt # Authenticate clients that want to use FTP over TLS? TLSVerifyClient off </IfModule> root@wl ~ # vi /etc/pam.conf ftp auth required /usr/lib/security/pam_unix.so ftp account required /usr/lib/security/pam_unix.so
# 익명 FTP에 사용할 계정을 만든다. Anonymous FTP를 이 사용자의 권한으로 실행될 것이다. root@wl ~ # /usr/sbin/groupadd -g 103 ftp root@wl ~ # useradd -d /export/home/ftp -g ftp -u 104 -s /bin/false ftp root@wl ~ # mkdir /export/home/ftp # Anonymous FTP의 홈 디렉토리. 소유자와 그룹 모두 root, staff로 놔둔다. root@wl ~ # vi /usr/local/proftpd/etc/proftpd.conf # Anonymous태그의 코멘트를 풀면 설정은 완료된다. # A basic anonymous configuration, no upload directories. If you do not # want anonymous users, simply delete this entire <Anonymous> section. <Anonymous ~ftp> User ftp Group ftp # We want clients to be able to login with "anonymous" as well as "ftp" UserAlias anonymous ftp # Limit the maximum number of anonymous logins MaxClients 10 # We want 'welcome.msg' displayed at login, and '.message' displayed # in each newly chdired directory. DisplayLogin welcome.msg # DisplayFirstChdir .message # Limit WRITE everywhere in the anonymous chroot <Limit WRITE> DenyAll </Limit> </Anonymous> root@wl ~ # pkill proftpd root@wl ~ # /usr/local/proftpd/sbin/proftpd익명 사용자도 업로드 할 수 있도록 incomming 디렉토리 만들어 보자. 장담하지만, 특별한 접근 제한이 없다면 일주일 이내에 WAREZ에 의해 장악된다. TCPWrapper등을 이용해 접근제한을 하지 않는다면, 실제 서비스에서는 하지 않는 것이 좋다.
root@wl ~ # mkdir /export/home/ftp/incomming root@wl ~ # chmod 777 /export/home/ftp/incomming root@wl ~ # vi /usr/local/proftpd/etc/proftpd.conf # 다음을 추가한다. <Anonymous ~ftp> ... # <Anonymous ~ftp>와 </Anonymous> 사이에 아래를 추가한다. <Directory incoming> AllowOverwrite on AllowStoreRestart on <Limit STOR MKD> AllowALL </Limit> </Directory> </Anonymous> root@wl ~ # pkill proftpd root@wl ~ # /usr/local/proftpd/sbin/proftpd # ProFTPD는 재시작하는 것이 없다.※ Anonymous의 User와 Group을 모두 ftp로 하였고, AnonymousFTP로 접속한 유저는 ftp:ftp권한을 가진다는 것을 생각하면 이해하기 쉬울 것이다.
root@wl ~ # vi /usr/local/proftpd/etc/proftpd.conf # TCPAccessFiles부분을 추가한다. TCPAccessFiles /etc/hosts.allow /etc/hosts.deny root@wl ~ # vi /etc/hosts.deny ALL:ALL root@wl ~ # vi /etc/hosts.allow proftpd: 192.168.0.3,192.168.0.2 root@wl ~ # pkill proftpd root@wl ~ # /usr/local/proftpd/sbin/proftpd
root@wl ~ # vi /usr/local/proftpd/etc/proftpd.conf # 아래부분을 추가한다. <IfModule mod_sql.c> SQLAuthenticate on SQLConnectInfo ftpdb@localhost root SQLAuthTypes Plaintext SQLLogFile /var/log/proftpdsqllog # SQLUserInfo users userid passwd uid gid homedir shell # SQLGroupInfo groups groupname gid members </IfModule>※ 위세팅은 localhost에 있는 MySQL의 ftpdb 데이터베이스를 사용하며, 사용자 이름은 root, 패스워드는 없다. 테이블 이름은 ftpusers, ftpgroups 이다. 만약 데이터베이스 접속에 패스워드가 필요하다면, [SQLConnectInfo ftp@localhost root]에 한칸 띄우고 패스워드를 써 주면 된다. 이제 MySQL을 세팅할 차례다.
root@wl ~ # mysql -u root
mysql> create database ftpdb;
Query OK, 1 row affected (0.00 sec)
mysql> use ftpdb
Database changed
mysql> CREATE TABLE users (
userid VARCHAR(30) NOT NULL UNIQUE,
passwd VARCHAR(80) NOT NULL,
uid INTEGER UNIQUE,
gid INTEGER,
homedir VARCHAR(255),
shell VARCHAR(255)
);
Query OK, 0 rows affected (0.00 sec)
mysql> CREATE TABLE groups (
groupname VARCHAR(30) NOT NULL,
gid INTEGER NOT NULL,
members VARCHAR(255)
);
Query OK, 0 rows affected (0.00 sec)
mysql> insert into users (userid, passwd, uid, gid, homedir, shell) values ('dbtest', 'test', 101, 10, '/export/home/windy', '/bin/bash');
Query OK, 1 row affected (0.00 sec)
mysql> insert into groups (groupname, gid, members) values ('staff', 10, 'dbtest');
Query OK, 1 row affected (0.00 sec)
mysql> exit
Bye
root@wl ~ # pkill proftpd
root@wl ~ # /usr/local/proftpd/sbin/proftpd
- 뭔가 이상하다면 /var/log/proftpdsqllog 파일을 확인해본다. 테이블이름의 기본값이 ProFTPD 버전마다 다른듯 하다.
root@wl ~ # tail /var/log/xferlog Fri Nov 11 11:56:28 2005 0 xxx.xxx.xxx.xxx zzzz /sample.txt a _ i r webmaster ftp 1 * c -----------------------1 2 --------------3 ---4 ----------5 6 7 8 9 -------10 -11 12 13 14로그시간 전송시간 원격호스트이름 파일크기 파일이름 전송종류 특별전송플래그 방향 접근모드 유저이름 서비스이름 인증방법 인증된유저ID 완료여부
|
|
Copyright © 2004-2010 Jo HoSeok. All rights reserved. |