mysql과 proftp 연동설정 정리
이 연동 자료는 2010 인미기초실습 수강생은 참조하지 말기 바랍니다.
아직 여기의 내용을 이해할 정도로 진도가 나가지 않았습니다.
그냥 기본 프로그램을 다운받아 make; make install 해서 설치하기 바랍니다.
또는 yum 으로 설치하기 바랍니다.
작성일시 : 2005.08.19
작성자 : 이승호
1. mysql 기본설치
설치버젼 mysql-4.0.24.tar.gz
2. proftp 소스 설치 옵션 부여
설치 버젼 proftpd-1.2.10.tar.gz
* configure 도중 헤더와 라이브러리 화일의 위치를 찾을수 없다고 나오면 아래와 같이 링크 시켜준다.
ln -s /usr/local/mysql/include/mysql /usr/include/mysql
ln -s /usr/local/mysql/lib/mysql/libmysqlclient.a /usr/lib/libmysqlclient.a
ln -s /usr/local/mysql/lib/mysql/libmysqlclient.so.12.0.0 /usr/lib/libmysqlclient.so.12
* configure 옵션
./configure --prefix=/usr/local/proftpd --with-modules=mod_sql:mod_sql_mysql \
--with-includes=/usr/include/mysql --with-libraries=/usr/lib \
--enable-autoshadow --enable-shadow
에러 없을시 make && make install
3. 데이터베이스 스키마
* users
create table users (
userid char(12) not null,
uid integer unsigned,
gid integer unsigned,
passwd char(63),
shell char(255),
homedir char(255),
count integer unsigned not null,
valid integer unsigned,
primary key (userid)
);
* groups
create table groups (
gname char(12) not null,
gid integer unsigned,
members text,
primary key(gname)
);
4. Proftp 설정
# This is a basic ProFTPD configuration file (rename it to
# 'proftpd.conf' for actual use. It establishes a single server
# and a single anonymous login. It assumes that you have a user/group
# "nobody" and "ftp" for normal operation and anon.
ServerName "ProFTPD Default Installation"
ServerType standalone
DefaultServer on
# Port 21 is the standard FTP port.
Port 21
# Umask 022 is a good standard umask to prevent new dirs and files
# from being group and world writable.
Umask 022
# To prevent DoS attacks, set the maximum number of child processes
# to 30. If you need to allow more than 30 concurrent connections
# at once, simply increase this value. Note that this ONLY works
# in standalone mode, in inetd mode you should use an inetd server
# that allows you to limit maximum number of processes per service
# (such as xinetd).
MaxInstances 30
ServerIdent off
UseReverseDNS off
IdentLookups off
DefaultRoot ~
# Set the user and group under which the server will run.
User nobody
Group nobody
# To cause every FTP user to be "jailed" (chrooted) into their home
# directory, uncomment this line.
# Normally, we want files to be overwriteable.
AllowOverwrite on
# Bar use of SITE CHMOD by default
<Limit SITE_CHMOD>
DenyAll
</Limit>
# MYSQL
SQLConnectInfo proftp@localhost:3306 proftp bwing1004
SQLUserInfo users userid passwd uid gid homedir shell
SQLUserWhereClause "valid = 1"
SQLLog PASS updatecount
SQLNamedQuery updatecount UPDATE "count=count+1 where userid='%u'" users
SQLAuthTypes Backend
SQLAuthenticate users
SQLDefaultGID 65534
SQLDefaultUID 65534
SQLMinUserGID 100
SQLMinUserUID 500
SQLDefaultHomedir /usr/local/mysql/data
SQLNamedQuery count SELECT "count from users where userid='%u'"
SQLShowInfo PASS "230" "%u님은 지금까지 %{count}번 접속하셨습니다."
SQLLogFile /var/log/proftp_sql.txt
# 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>
5. 사용자 생성 Query
insert into users values ('userID',uid,gid,PASSWORD('비밀번호'),'shell','homedir',count,valid);
예) insert into users values ('admin',NULL,NULL,PASSWORD('admin1004'),'/bin/sh','/home/admin',0,1);
6. 기타 설정 사항
* 사용자 디렉토리 퍼미션 777 되있어야 데이터 업로드 가능
* group 테이블을 사용하지 않으면 SQLAuthenticate users 로 바꿔서 사용
7. proftp 설정에 관한 설명
* SQLConnectInfo DB명@호스트:포트 아이디 패스워드
: 위에서 우리는 proftp라는 이름으로 데이타베이스를 생성했으므로, <DB명>에
'proftp'를 적어준다. <호스트>는 일반적으로 'localhost'를 적어주나, 만약
다른 서버에 생성하였다면 그 호스트 이름이나 IP를 적는다. <포트>는 기본이
'3306'이나 포트를 변경하였다면 변경한 포트를 적는다.
<아이디>는 MySQL에서 proftp 데이타베이스를 사용할 수 있는 사용자 계정 -
시스템 사용자 계정이 아니다. 잘 모르겠으면 MySQL 문서 중 사용자 관리
항목을 천천히 읽어본 후 아래를 진행하기 바란다 - 을 입력하고, <패스워드>
에는... (말 안해도 다 알 것이다 ^^;;)
* SQLUserTable users
: 사용자 계정을 관리하는 테이블을 정의한다.
* SQLWhereClause "valid = 1"
: 사용자 계정에서 쿼리를 수행할 경우 추가적으로 덧붙일 구문을 적어준다.
우리는 위에서 'valid'라는 필드를 가지고 있으며, 이 필드는 사용자 계정을
임시적으로 막거나 해제하기 위해 사용한다고 기술한바 있다.
여기서는 "valid = 1"이 덧붙여져서 쿼리가 실행되므로, valid 필드만
0 이나 NULL 로 변경하면 이 계정 사용자는 더이상 로그인 할 수가 없다.
* SQLUsernameField userid
: 사용자 계정 필드
* SQLUidField uid
: 사용자 계정의 UID
* SQLGidField gid
: 사용자가 속한 그룹의 GID
* SQLPasswordField passwd
: 계정의 패스워드
* SQLHomedirField homedir
: 이 계정의 사용자를 위한 홈 디렉토리. 테이블에서는 시스템의 전체 경로로
등록하여야 한다. (예: /var/ftp/pub)
* SQLShellField shell
: 이 계정의 사용자를 위한 쉘. 테이블에서 이 항목이 비어 있거나 사용할 수 없는
쉘이 지정되어 있을 경우에는 로그인 되지 않는다. (예: /bin/sh)
* SQLLoginCountField count
: 사용자의 누적 로그인 카운트. 이 필드는 ProFTP에 의해서 자동으로 증가한다.
* SQLAuthTypes Backend
: 만약 password 필드에 패스워드를 넣기 위해 MySQL 내부 함수 중 PASSWORD()를
사용하였다면 이와 같이 'Backend'로 지정하고, 일반 텍스트로 입력한 경우에는
'Plaintext'로 지정한다.
* SQLDoAuth on
: SQL 로그인 관리를 할 것인지 말 것인지 지정한다. 이 항목을 off 시키면,
SQLDoGroupAuth 나 SQLAuthoritative 등 다른 모든 항목을 무효화 시킨다.
* SQLDoGroupAuth off
: 그룹 관리를 할 것인지 말 것인지를 지정한다. 이 강좌에서는 그룹 관리를 하지
않으며 이에 관한 것은 글을 읽는 사람의 몫으로 남겨둔다.
* SQLHomedir /var/ftp
: <homedir> 필드가 비어 있을 경우 기본으로 사용할 경로를 지정한다. 여기서는
/var/ftp 로 되어 있으며, <homedir>가 정의되지 않은 사용자는 /var/ftp로
로그인 된다.
/usr/local/sbin/proftpd -d 5 -n -c /usr/local/etc/proftpd.conf
* 참고 url http://www.castaglia.org/proftpd/modules/mod_sql.html
실제 세팅된 proftpd
[CentOS][proftpd] 환경설정 고급? 옵션
MaxClientsPerHost [최대 접속수] ["메세지"]
MaxHostsPerUser [최대 접속수] ["메시지"]
TimeoutIdel 600
TimeoutNoTransfer 600
TimeoutLogin 300
UpTime 10 service
DonwTime 23 service
ShowSymlinks on | off
PassivePorts min-pasv-port max-pasv-port
<Limit command | command-group[command2 ..]>
AnonRequirePassword on | off
RootLogin off
MaxStoreFileSize
MaxRetrieveFileSize
TransferRate RETR,STOR 1024000
ServerAdmin maybemaster@naver.com
DeferWelcom on
UserReverseDNS off
IdentLookups off
HideUser root
HideGroup root
proftpd 1.3.2