'팁&테크/Linux'에 해당되는 글 69건

  1. 2010.09.16 JOSSO를 통한 SSO 구현하기
  2. 2010.08.19 Cron 관련
  3. 2010.05.31 메일서버(sendmail,saslauthd,dovecot) 세팅
  4. 2010.05.31 리눅스 메일계정 추가
  5. 2010.04.30 포트 오픈 확인
  6. 2010.04.28 Domain Name Server (DNS) configuration using Bind version 8 or 9
  7. 2010.04.28 vsFTPd and FTP user account configuration
  8. 2010.04.28 Apache HTTP Web server configuration
  9. 2010.04.22 vsftpd 설정
  10. 2009.03.27 리눅스 터미널에서 한글 깨질때 해결 방법
2010. 9. 16. 15:21

JOSSO를 통한 SSO 구현하기

먼저 아래테이블을 보고 설치할 플랫폼을 알아보자.
Gateway는 Server 라고 생각하면 되고 Agent는 Client 라 생각하면 된다.
PlatformAgent (SP)Gateway (IdP)
JBoss 5.x
JBoss 4.2.x
JBoss 4.0.x
JBoss 3.2.6+
Tomcat 6.0
Tomcat 5.5
Tomcat 5.0
Weblogic 10.0
Weblogic 9.2
Websphere CE
Geronimo 2.1
Generic J2EE / JEE
Jetty 6.x
Apache 2.2 (php, perl, python, ...)  
PHP 4.x,5.x  
Microsoft IIS (ASP, .NET, ...)  
Liferay 5.2.x  
Alfresco 3.3  
phpBB  

먼저 나는 SSO Gateway 로는 Centos 5.5 리눅스에 Tomcat 5.5 를 YUM(rpm)으로 설치를 한 상태이다.
그래서 Tomcat 5.5 Gateway를 설치했다. Agent 는 PHP 를 사용할 것이다.
아 그리고 톰캣이 설치되있으니 jdk 역시 설치되어있다. jdk 역시 YUM(rpm)으로 설치가 되 있다.

아래에 나오는 모든 경로는 YUM으로 설치시 설정되는 경로이다. 소스로 설치를 하였다면 해당 경로로 변경해야 한다.

Tomcat 5.5를 다운받아서 서버에서 압축을 해제하고 디렉토레를 보면 /bin 디렉토리가 있는데
그곳에 리눅스용 실행파일이 있다. 필자의 경우에는 josso-gsh 라는 이름으로 쉘 파일이 존재하고 .bat 파일도 있는데 이것은 윈도우용이라 생각된다. 그리고 실행전 반드시 $JAVA_HOME 이 설정되어 있어야 한다. 

josso-gsh 를 실행하면 다시 josso> 라는 코맨드라인이 생기고 아래 명령을 실행해 Gateway를 설치하면 된다.

gateway install --target /usr/share/tomcat5 --platform tc55

여기서 --target에는 tomcat 설치 디렉토리를 --platform 에는 톰캣 버젼을 넣으면 된다.
YUM으로 설치시에 기본 디렉토리는 위와같이 /usr/share/tomcat5 이고 내용을 보면 대부분 다른 경로로 링크가 걸린 디렉토리 이다.(깔아보면 무슨말인지 알것임)
그리고 톰캣6.0을 사용한다면 --platform 에 값을 tc60으로 하면 된다.

그리고 Gateway는 기본적으로 MySql을 사용하므로 설치되어 있지 않다면 YUM으로 설치를 하자.
yum install mysql mysql-server mysql-devel

이제 josso에서 사용할 데이타베이스가 필요한데 데이타베이스를 생성하고 아래와 같이 테이블을 생성하자.
당연히 사용자도 추가해야함.
DROP TABLE IF EXISTS `josso_role`;
CREATE TABLE `josso_role` (
  `name` VARCHAR(16) NOT NULL,
  `description` VARCHAR(64) DEFAULT NULL,
  PRIMARY KEY (`name`)
) ENGINE=INNODB DEFAULT CHARSET=euckr;

DROP TABLE IF EXISTS `josso_user`;
CREATE TABLE `josso_user` (
  `login` VARCHAR(16) NOT NULL,
  `passwd` VARCHAR(20) NOT NULL,
  `name` VARCHAR(64) DEFAULT NULL,
  `description` VARCHAR(64) DEFAULT NULL,
  PRIMARY KEY (`login`)
) ENGINE=INNODB DEFAULT CHARSET=euckr;

DROP TABLE IF EXISTS `josso_user_property`;
CREATE TABLE `josso_user_property` (
  `login` VARCHAR(16) NOT NULL,
  `name` VARCHAR(255) NOT NULL,
  `value` VARCHAR(255) NOT NULL,
  PRIMARY KEY (`login`,`name`), 
  CONSTRAINT `josso_user_property_ibfk_1` 
    FOREIGN KEY (`login`) REFERENCES `josso_user` (`login`)
) ENGINE=INNODB DEFAULT CHARSET=euckr; 

DROP TABLE IF EXISTS `josso_user_role`;
CREATE TABLE `josso_user_role` (
  `login` VARCHAR(16) NOT NULL,
  `name` VARCHAR(255) NOT NULL,
  PRIMARY KEY (`login`,`name`),
  KEY `name` (`name`),
  CONSTRAINT `josso_user_role_ibfk_2` 
    FOREIGN KEY (`login`) REFERENCES `josso_user` (`login`),
  CONSTRAINT `josso_user_role_ibfk_1` 
    FOREIGN KEY (`name`) REFERENCES `josso_role` (`name`)
) ENGINE=INNODB DEFAULT CHARSET=euckr;

그다음은 josso에서 사용할 JDBC 드라이버를 설치해보자.
MySQL JDBC Driver 다운로드 사이트 에가서 JDBC Driver for MySql 파일을 받고 서버에서 압축 풀어서
mysql-connect-java-???.jar 파일을 /usr/share/tomcat5/webapps/josso/WEB-INF/lib 경로에 복사를 하자.

그 다음은 사용자의 로그인 정보를 어느 방식으로 저장하고 사용할지를 설정해야 한다. 보통 MySql을 사용하지만 메모리를 사용할수도 있다.
/usr/share/tomcat5/common/classes/josso-gateway-config.xml 파일을 열어 아래 라인을 다음과 같이 고치도록 하자.
<!-- Identity, Session and Assertion Stores configuration -->
<s:import resource="josso-gateway-stores.xml" />
이부분을
<s:import resource="josso-gateway-db-stores.xml" />
이렇게 수정을 하면 기본적으로 메모리에 저장되도록 되있는 부분을 DB로 변경하게 된다.

그럼 위에 설정한 josso-gateway-db-stores.xml 파일에 MySql 계정 설정을 아래와 같이 하자.
<db-istore:jdbc-store
    id="josso-identity-store"
    driverName="com.mysql.jdbc.Driver"
    connectionURL="jdbc:mysql://localhost:3306/데이타베이스명"
    connectionName="아이디"
    connectionPassword="비번"
    userQueryString="SELECT LOGIN AS NAME FROM JOSSO_USER WHERE LOGIN = ?"
    rolesQueryString="SELECT NAME AS ROLE FROM JOSSO_USER_ROLE WHERE LOGIN = ?"
    credentialsQueryString="SELECT LOGIN AS USERNAME, PASSWD password FROM JOSSO_USER WHERE LOGIN = ?"
    userPropertiesQueryString="SELECT NAME, VALUE FROM JOSSO_USER_PROPERTY WHERE LOGIN = ?"
    resetCredentialDml="UPDATE JOSSO_USER SET PASSWD = ? WHERE LOGIN = ?"
    relayCredentialQueryString="SELECT LOGIN FROM JOSSO_USER WHERE #?# = ?"
    />

자 Gateway 마지막으로 josso-gateway-auth.xml 파일에서 기본인증정보를 수정한다.
hashAlgorithm, hashEncoding를 삭제하여 암호를 일반텍스트로 저장하도록 하자.
<basic-authscheme:basic-auth-scheme
           id="josso-basic-authentication"
           ignorePasswordCase="false"
           ignoreUserCase="false">

       <basic-authscheme:credentialStore>
           <s:ref bean="josso-identity-store"/>
       </basic-authscheme:credentialStore>

       <basic-authscheme:credentialStoreKeyAdapter>
           <s:ref bean="josso-simple-key-adapter"/>
       </basic-authscheme:credentialStoreKeyAdapter>

   </basic-authscheme:basic-auth-scheme>

오늘은 여기까지. 작업이 끝나면 이미지도 올리고 다시 정리를 할것임.

2010. 8. 19. 15:20

Cron 관련


Cron 관련 설정은 /etc/crontab 에 있음

SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/

# run-parts
01 * * * * root run-parts /etc/cron.hourly
02 4 * * * root run-parts /etc/cron.daily
22 4 * * 0 root run-parts /etc/cron.weekly
42 4 1 * * root run-parts /etc/cron.monthly


실행 결과를 매번 메일로 발송하는데 MAILTO="" 와 같이 처리하면
Cron 에서 메일을 보내지 않게 됨

2010. 5. 31. 16:58

메일서버(sendmail,saslauthd,dovecot) 세팅


// 설치 //

1. yum install sendmail (centos5 설치시 기본설치되어있음)
2. yum install sendmail-cf ( sasl 설정을 위해 깔아야 함)
3. yum install dovecot ( pop3 서버 설치)

// sendmail 설정 //
1. vi /etc/mail/sendmail.cf
   -> #Cwlocalhost (주석처리)
   -> DaemonPortOption=port=stmp,Name=MTA
2. vi /etc/mail/local-host-names
   -> localhost
   -> example.com.kr
   -> example.comm 등 메일서버의 도메인명 기록
3. vi /etc/mail/access
   -> localhost.localdomain RELAY
   -> localhost   RELAY
   -> example.co.kr  RELAY
   -> mail.example.co.kr  RELAY
   -> example.com  RELAY
   -> mail.example.com  RELAY
   ... 등 메일서버 이용을 허용하는 도메인 또는 IP주소
4. makemap hash /etc/mail/access < /etc/mail/access (access.db 생성)

   makemap hash /etc/mail/virtusertable < /etc/mail/virtusertable

   makemap hash /etc/mail/domaintable < /etc/mail/domaintable
   makemap hash /etc/mail/mailertable < /etc/mail/mailertable


5. service sendmail start

// sasl 설정 //
1. vi /etc/mail/sendmail.mc
   -> dnl 주석풀기
      TRUST_AUTH_MECH(`EXTERNAL DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl
      define(`confAUTH_MECHANISMS', `EXTERNAL GSSAPI DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl
   -> Addr 을 0.0.0.0 으로 변경 
      Daemon_Option ('port=smtp,Addr=0.0.0.0,Name=MTA')dnl
2. m4 /etc/mail/sendmail.mc > /etc/sendmail.cf (sendmail.cf 파일 재 생성, sendmail-cf 가 깔려있어야 에러없음)
3. vi /etc/mail/sendmail.cf
   -> #Cwlocalhost (주석처리)
4. service sendmail restart
5. service saslauthd restart
6. telnet localhost 25
   -> ehlo localhost
      auth Login Plain 나오면 성공

 

//  pop3 서버 구축(dovecot 추천) //

환경설정
1. vim /etc/dovecot.conf
   -> protocols = imap imaps pop3 pop3s (주석풀고 설정)
   -> listen = [::]

서비스추가
2. ntsysv -> dovecot 서비스 체크

서비스 실행
3. service dovecot start

 

// 서비스 동작 확인 //
1. telnet localhost 110
   -> user myid(계정명)
      +OK Password required for myid.
   -> pass 1234(패스워드)
      +OK myid has 0 visible messages (0 hidden) in 0 octets.
   -> quit

// 관리자 계정 추가(master@aaa.com, webmaster@aaa.com) //
  1. adduser webmaster
  2. passwd webmaster
  3. vi /etc/aliases
     -> 맨아래 # Person who should get root's mail
        root:           myid,webmaster (주석풀고 계정명 추가, root계정으로 오는메일을 myid,webmaster계정도 받아볼수 있음)
  4. cd /etc
  5. makemap hash aliases < aliases (aliases.db생성)
  6. 확인 : strings /etc/aliases.db | grep 계정명

참고) 디렉토리 생성없이 계정만 추가 : adduser -M 계정명
      디렉토리 삭제동반하는 계정삭제 : userdel -r 계정명

주의 : 아웃룩에서 POP3 설정시 메일을 못 받아올 경우
         /home/계정/mail 폴더가 없어서 그런것이니 -M 옵션을 사용하면 안됨
2010. 5. 31. 16:47

리눅스 메일계정 추가


cd /etc/mail/ ==> 메일 설정을 하기위해 mail 디렉토리로 이동

#vi local-host-names ==> 추가할 도메인 네임
test.co.kr
nayana.com

#vi virtusertable ==> 메일 계정을 추가할 파일 이름

사용할 메일주소 메일계정

webmaster@test.co.kr webmaster
admin@test.co.kr admin

rich76@nayana.com rich76 ==> 추가된 메일주소와 계정

#useradd -M rich76 -s /bin/false -g mail ==> 메일 계정 생성 방법

#passwd rich76 ==> 패스워드 설정

#make all ==> sendmail 컴파일

#/etc/rc.d/init.d/sendmail restart ==> 데몬 다시시작
 
2010. 4. 30. 17:27

포트 오픈 확인

TCP포트 확인방법(1~1024포트 범위 검색)
nmap -sT -p 1-1024 localhost

UDP포트 오픈 확인방법(1~1024포트 범위 검색)
nmap -sU -p 1-1024 localhost
2010. 4. 28. 16:18

Domain Name Server (DNS) configuration using Bind version 8 or 9

Two of the most popular ways to configure the program Bind (Berkeley Internet Domain software) to perform DNS services is in the role of (1) ISP or (2) Web Host.

  1. In an ISP configuration for clients (web surfers) conected to the internet, the DNS server must resolve IP addresses for any URL the user wishes to visit.
  2. In a purely web hosting configuration, Bind will only resolve for the IP addresses of the domains which are being hosted. This is the configuration which will be discussed and is often called an "Authoritative-only Nameserver".

When resolving IP addresses for a domain, Internic is expecting a "Primary" and a "Secondary" DNS name server. (Sometimes called Master and Slave) Each DNS name server requires the file /etc/named.conf and the files it points to. This is typically two separate computer systems hosted on two different IP addresses. It is not necesary that the Linux servers be dedicated to DNS as they may run a web server, mail server, etc.

Note on Bind versions: Red Hat versions 6.x used Bind version 8. Release 7.1 of Red Hat began using Bind version 9 and the GUI configuration tool bindconf was introduced for those of you that like a pretty point and click interface for configuration.

Installation Packages:

  • Red Hat / Fedora Core / CentOS: bind, bind-chroot, bind-libs, bind-utils, system-config-bind
    • bind-chroot: Security jail for operation of bind.
    • bind-utils: Utility commands like nslookup, host, dig
    • system-config-bind: GUI config tool system-config-bind and related configuration files (/etc/security/console.apps/bindconf).
    • caching-nameserver: We will not be covering this as it is not required for web hosting. This is used by internet providers so their clients can cache the DNS entries of the sites they are visiting.
  • Ubuntu (dapper/hardy) / Debian: bind9

Configuration files:

Red Hat / Fedora / CentOS:
File Description Directory Chrooted Directory
named.conf Primary/Secondary DNS server configuration.
(See default file /usr/share/doc/bind-9.X.X/sample/etc/named.conf)
/etc/ /var/named/chroot/etc/
named.root.hints Configuration for recursive service. Required for all zones.
(See default file /usr/share/doc/bind-9.X.X/sample/etc/named.root.hints)
/etc/ /var/named/chroot/etc/
named Red Hat system variables. /etc/sysconfig/ no change
rndc.key Primary/Secondary DNS server configuration. /etc/ /var/named/chroot/etc/
Zone files Configuration files for each domain. Create this file to resolve host name internet queries i.e. define IP address of web (www) and mail servers in the domain. /var/named/ /var/named/chroot/var/named/

Debian / Ubuntu:
File Description Directory Chrooted Directory
named.conf
named.conf.options
named.conf.local
Primary/Secondary DNS server configuration. /etc/bind/ /var/bind/chroot/etc/bind/
rndc.key Primary/Secondary DNS server configuration. /etc/ /var/bind/chroot/etc/
Zone files Configuration files for each domain. /var/bind/data/ /var/bind/chroot/var/bind/data/

Primary server (master):

File: named.conf

Red Hat / Fedora Core / CentOS: /etc/named.conf (chroot dir: /var/named/chroot/etc/named.conf) and /etc/sysconfig/named for system variables.
Ubuntu / Debian: /etc/bind/named.conf Place local definitions in /etc/bind/named.conf.options and /etc/bind/named.conf.local

Simple example: (no views)
options {                                     - Ubuntu stores options in /etc/bind/named.conf.options
        version "Bind";                       - Don't disclose real version to hackers
        directory "/var/named";               - Specified so relative path names can be used. Full path names still allowed.
        allow-transfer { XXX.XXX.XXX.XXX; };  - IP address of secondary DNS
        recursion no;
        auth-nxdomain no;                     - conform to RFC1035. (default)
        fetch-glue no;                  - Bind 8 only! Not used by version 9
};

zone "localhost" {
        type master;
        file "/etc/bind/db.local";
};
zone "0.0.127.in-addr.arpa" {
        type master;
        file "/etc/bind/db.127";
};

zone "your-domain.com"{                 - Ubuntu separates the zone definitions into /etc/bind/named.conf.local 
        type master;                    - Specify master, slave, forward or hint
        file "data/named.your-domain.com"; 
        notify yes;                     - slave servers are notified when the zone is updated.
        allow-update { none; };         - deny updates from other hosts (default: none)
        allow-query { any; };           - allow clients to query this server (default: any)
};
zone "your-domain-2.com"{
        type master;
        file "data/named.your-domain-2.com";
        notify yes;
};
Note:
  • The omission of zone ".". Required if providing a recursive service.
  • Ubuntu includes the separated file of zone directives using the directive:
    include "/etc/bind/named.conf.local";

BIND Views: The BIND naming service can support "views" which allow various sub-networks (i.e. private internal or public external networks) to have a different domain name resolution result.
  • If no views are specified then use the configuration shown above.
  • The match-up between the "view" and the view client which receives the DNS information is specified by the match-clients statement.
  • If even one view is specified, then ALL zones MUST be associated with a "view".
  • Bind 9 allows for views which allow different zones to be served to different types of clients, localhost, private networks and public networks. This maps to the three view names "localhost_resolver", "internal" and "external":
    • localhost_resolver: Supports name resolution for the system (localhost) using BIND. Support for use of bind also has to be configured in /etc/nsswitch.conf
    • internal: User specified Local Area Network (LAN). If not used to support a local private LAN, remove (or comment out) this view.
    • external: The general public internet defined as client "any".
  • If you are only setting up a caching name server, then only specify the view "localhost_resolver" (delete all other views).
  • In order to support a DNS for internet domains using views, one will have to configure an "external" view

Typical Red Hat Enterprise 5 example: (Bind 9.3.4 with three "views")
options
{
        directory "/var/named"; // the default
        dump-file               "data/cache_dump.db";
        statistics-file         "data/named_stats.txt";
        memstatistics-file      "data/named_mem_stats.txt";

};
logging
{
    //  By default, SELinux policy does not allow named to modify the /var/named
    //  directory, so put the default debug log file in data/ :
 
        channel default_debug {
                file "data/named.run";
                severity dynamic;
        };
};
view "localhost_resolver"
{
    //  This view sets up named to be a localhost resolver ( caching only nameserver ).
    //  If all you want is a caching-only nameserver, then you need only define this view:
    match-clients           { localhost; };
    ...
};
view "internal"
{
    // This view will contain zones you want to serve only to "internal" clients
    // that connect via your directly attached LAN interfaces - "localnets" .
    // For local private LAN. Not covered in this tutorial.
    // Delete this view if web hosting with no local LAN.
    match-clients           { localnets; };
    ...
};
key ddns_key
{
        algorithm hmac-md5;
        secret "use /usr/sbin/dns-keygen to generate TSIG keys";
};
view    "external"
{
    // This view will contain zones you want to serve only to "external" 
    // public internet clients. This is covered below.
    match-clients           { any; };
    ...
    .. 
};
          

Default configuration files: Red Hat may supply the default configuration in: /usr/share/doc/bind-9.X.X/sample/etc/named.conf
  • cp /usr/share/doc/bind-9.X.X/sample/etc/named.conf /var/named/chroot/etc
  • cp /usr/share/doc/bind-9.X.X/sample/etc/named.root.hints /var/named/chroot/etc
  • chcon -u system_u -r object_r -t named_conf_t /var/named/chroot/etc/named.conf /var/named/chroot/etc/named.root.hints

view "localhost_resolver": If supporting a caching DNS server (not required to support a web domain) you will also need the files:
  • cp /usr/share/doc/bind-9.X.X/sample/etc/named.rfc1912.zones /var/named/chroot/etc
  • cp /usr/share/doc/bind-9.X.X/sample/var/named/localdomain.zones /var/named/chroot/var/named
    also from /usr/share/doc/bind-9.X.X/sample/var/named/: localhost.zones, named.local, named.zero, named.broadcast, named.ip6.local, named.root

view "external": (master) - details -
view    "external"
{
/* This view will contain zones you want to serve only to "external" clients
 * that have addresses that are not on your directly attached LAN interface subnets:
 */
        match-clients           { any; };
        match-destinations      { any; };
        allow-transfer { XXX.XXX.XXX.XXX; };  - IP address of secondary DNS

        recursion no;
        // you'd probably want to deny recursion to external clients, so you don't
        // end up providing free DNS service to all takers

        // all views must contain the root hints zone:
        include "/etc/named.root.hints";

        // These are your "authoritative" external zones, and would probably
        // contain entries for just your web and mail servers:

        zone "your-domain.com" {
                type master;
                file "/var/named/data/external/named.your-domain.com";
                notify yes;
                allow-update { none; };
        };
 
        // You can also add the zones as a separate file like they do in Ubuntu by adding the following statement
        include "/etc/named.conf.local";      
};

DNS key:

Use the following command /usr/sbin/dns-keygen to create a key. Add this key to the "secret" statement as follows:
key ddns_key
{
        algorithm hmac-md5;
        secret "XlYKYLF5Y7YOYFFFY6YiYYXyFFFFBYYYYFfYYYJiYFYFYYLVrnrWrrrqrrrq";
};

Man Pages:
  • named.conf

Forward Zone File: /var/named/named.your-domain.com

Red Hat 9 / CentOS 3: /var/named/named.your-domain.com
Red Hat EL4/5, Fedora 3+, CentOS 4/5: [Chrooted] /var/named/chroot/var/named/data/named.your-domain.com
Red Hat EL4/5, Fedora 3+, CentOS 4/5: /var/named/data/named.your-domain.com
Ubuntu / Debian: /etc/bind/data/named.your-domain.com
$TTL 604800         - Bind 9 (and some of the later versions of Bind 8) requires $TTL statement. Measured in seconds. This value is 7 days.
your-domain.com.    IN      SOA  ns1.your-domain.com.  hostmaster.your-domain.com. (
   2000021600 ; serial     - Many people use year+month+day+integer as a system. Never greater than 2147483647 for a 32 bit processor.
   86400 ; refresh         - How often secondary servers (in seconds) should check in for changes in serial number. (86400 sec = 24 hrs)
   7200 ; retry            - How long secondary server should wait for a retry if contact failed.
   1209600 ; expire        - Secondary server to purge info after this length of time.
   86400 ) ; default_ttl   - How long data is held in cache by remote servers.
       IN A       XXX.XXX.XXX.XXX  - Note that this is the default IP address of the domain. 
                                     I put the web server IP address here so that domain.com points to the same servers as www.domain.com
;
; Name servers for the domain
;
       IN NS         ns1.your-domain.com.
       IN NS         ns2.your-domain.com.
;
; Mail server for domain
;
       IN MX    5    mail               - Identify "mail" as the node handling mail for the domain. Do NOT specify an IP address!
;
; Nodes in domain
;
node1  IN A          XXX.XXX.XXX.XXX    - Note that this is the IP address of node1
ns1    IN A          XXX.XXX.XXX.XXX    - Optional: For hosting your own primary name server. Note that this is the IP address of ns1
ns2    IN A          XXX.XXX.XXX.XXX    - Optional: For hosting your own secondary name server. Note that this is the IP address of ns2
mail   IN A          XXX.XXX.XXX.XXX    - Identify the IP address for node mail.
       IN MX    5    XXX.XXX.XXX.XXX    - Identify the IP address for mail server named "mail".
;
; Aliases to existing nodes in domain
;
www    IN CNAME      node1              - Define the webserver "www" to be node1.
ftp    IN CNAME      node1              - Define the ftp server to be node1.
                

MX records for 3rd party off-site mail servers:

your-domain.com.    IN MX  10 mail1.offsitemail.com.
your-domain.com.    IN MX  20 mail2.offsitemail.com.
      
Append to the above file.

Initial configuration: Note that Red Hat may supply the default zone configuration in: /usr/share/doc/bind-9.X.X/sample/var/named/

  • cp /usr/share/doc/bind-9.X.X/sample/var/named/localhost.zone /var/named/chroot/var/named/data/
  • cp /usr/share/doc/bind-9.X.X/sample/var/named/localdomain.zone /var/named/chroot/var/named/data/
  • cp /usr/share/doc/bind-9.X.X/sample/var/named/named.broadcast /var/named/chroot/var/named/data/
  • cp /usr/share/doc/bind-9.X.X/sample/var/named/named.ip6.local /var/named/chroot/var/named/data/
  • cp /usr/share/doc/bind-9.X.X/sample/var/named/named.zero /var/named/chroot/var/named/data/
  • cp /usr/share/doc/bind-9.X.X/sample/var/named/named.local /var/named/chroot/var/named/data/
  • cp /usr/share/doc/bind-9.X.X/sample/var/named/named.root /var/named/chroot/var/named/data/
  • cd /var/named/chroot/var/named/data/
  • chcon -u system_u -r object_r -t named_cache_t localhost.zone localdomain.zone named.broadcast named.ip6.local named.zero named.root named.local

A file suffix of "zone" is also common i.e. your-domain.com.zone

Secondary server (slave):

File: named.conf

Red Hat / Fedora Core / CentOS: /etc/named.conf
Ubuntu / Debian: /etc/bind/named.conf
Simple example with no views:
options {                               - Ubuntu stores options in /etc/bind/named.conf.options
        version "Bind";                 - Don't disclose real version to hackers
        directory "/var/named";
        allow-transfer { none; };       - Slave is not transfering updates to anyone else
        recursion no;
        auth-nxdomain no;               - conform to RFC1035. (default)
        fetch-glue no;                  - Bind 8 only! Not used by version 9
};
zone "localhost" {
        type master;
        file "/etc/bind/db.local";       - Ubutu: /etc/bind/db.local, Red Hat: /var/named/named.local
};
zone "0.0.127.in-addr.arpa" {
        type master;
        file "/etc/bind/db.127";
};

zone "your-domain.com"{
        type slave;          
        file "named.your-domain.com";   - Specify slaves/named.your-domain.com for RHEL4/5 chrooted bind
        masters { XXX.XXX.XXX.XXX; };   - IP address of primary DNS
};
zone "your-domain-2.com"{
        type slave;          
        file "named.your-domain-2.com";
        masters { XXX.XXX.XXX.XXX; };
};
                

view "external": (slave)
view    "external"
{
        match-clients           { any; };
        match-destinations      { any; };
        allow-transfer { none; };  - Slave does not transfer to anyone, slave receives
        recursion no;
        include "/etc/named.root.hints";

        zone "your-domain.com" {
                type slave;
                file "/var/named/slaves/external/named.your-domain.com";
                notify no;                  - Slave does not notify, slave is notified by master
                masters { XXX.XXX.XXX.XXX; }; - State IP of master server
        };
};
Note: RHEL4/5, CentOS 4/5, Fedora 3+ use chrooted directory structure permissions which require the use of the slaves subdirectory /var/named/slaves

Slave Zone Files: These are transfered from master to slave and chached by slave. There is no need to generate a zone file on the slave.

Additional Information:

  • Man page on named.conf
  • Man page on named DNS server
  • Full DNS manual

[Potential Pitfall]: Ubuntu dapper/hardy - Path names used can not violate Apparmor security rules as defined in /etc/apparmor.d/usr.sbin.named. Note that the slave files are typically named "/var/lib/bind/named.your-domain.com" as permitted by the security configuration.

[Potential Pitfall]: Ubuntu dapper/hardy - Create log file and set ownership and permission for file not created by installation:

  • touch /var/log/bindlog
  • chown root.bind /var/log/bindlog
  • chmod 664 /var/log/bindlog

[Potential Pitfall]: Error in /var/log/messages:

transfer of 'yolinux.com/IN' from XXX.XXX.XXX.XXX#53: failed while receiving responses: permission denied
Named needs write permission on the directory containing the file. This condition often occurs for a new "slave" or "secondary" name server where the zone files do not yet exist.
The default (RHEL4/5, CentOS 4/5, Fedora Core 3+, ...):
  • drwxr-x--- 4 root named 4096 Aug 25 2004 named
  • drwxrwx--- 2 named named 4096 Sep 17 20:37 slaves

Fix: In named.conf specify that the slaves to go to slaves directory /var/named/chroot/var/named/slaves with the directive:
file "slaves/named.your-domain.com";

Bind Defaults:

  • Uses port 53 if none is specified with the listen-on port statement.
  • Bind will use random ports above port 1024 for queries. For use with firewalls expecting all DNS traffic on port 53, specify the following option statement in /etc/named.conf
    query-source address * port 53;
    query-source-v6 port 53;
                    
  • Logging is to /var/log/messages

After the configuration files have been edited, restart the name daemon.

/etc/init.d/named restart

(Note: Ubuntu / Debian restart: /etc/init.d/bind9 restart)

Bind zone transfers work best if the clocks of the two systems are synchronised.
File: /var/named/named.your-domain.com This is created for you by Bind on the slave (secondary) server when it replicates from Primary server.


Test DNS:

Must install packages:

  • Red Hat / Fedora Core / SuSE: bind-utils
  • Ubuntu (dapper/hardy) / Debian: bind9-host
Test the name server with the host command in interactive mode:
   host  node.domain-to-test.com your-nameserver-to-test.domain.com
          
Note: The name server may also be specified by IP address.

or

Test the name server with the nslookup command in interactive mode:

   nslookup
> server your-nameserver-to-test.domain.com > node.domain-to-test.com > exit

Test the MX record if appropriate:

   nslookup -querytype=mx domain-to-test.com
   
   OR

   host -t mx domain-to-test.com
          

Test using the dig command:

   dig @name-server domain-to-query

   OR

   dig @IP-address-of-name-server domain-to-query
          

Test your DNS with the following DNS diagnostics web site: DnsStuff.com


Extra logging to monitor Bind:

Add the following to your /etc/named.conf file.
logging {
        channel bindlog {
                           file "/var/log/bindlog"  versions 5 size 1m;     - Keep five old versions of the log-file (rotates logs)
                           print-time yes;
                           print-category yes;
                           print-severity yes;
                        };
/*      If you want to enable debugging, eg. using the 'rndc trace' command,
 *      named will try to write the 'named.run' file in the $directory (/var/named).
 *      By default, SELinux policy does not allow named to modify the /var/named directory,
 *      so put the default debug log file in data/ :
 */
        channel default_debug {
                file "data/named.run";
                severity dynamic;
        };
        category xfer-out { bindlog; };         - Zone transfers
        category xfer-in  { bindlog; };         - Zone transfers
        category security { bindlog; };         - Approved/unapproved requests

//      The following logging statements, panic, insist and response-checks are valid for Bind 8 only. Do not user for version 9.
        category panic { bindlog; };            - System shutdowns
        category insist { bindlog; };           - Internal consistency check failures
        category response-checks { bindlog; };  - Messages
};
                


Chroot Bind for extra security:

Note: Most modern Linux distributions default to a "chrooted" installation. This technique runs the Bind name service with a view of the filesystem which changes the definition of the root directory "/" to a directory in which Bind will operate. i.e. /var/named/chroot.

The following example uses the Red Hat RPM bind-8.2.3-0.6.x.i386.rpm. Applies to Bind version 9 as well.

The latest RedHat bind updates run the named as user "named" to avoid a lot of earlier hacker exploits. To chroot the process is to create an even more secure environment by limiting the view of the system that the process can access. The process is limited to the chrooted directory assigned.

The chroot of the named process to a directory under a given user will prevent the possibility of an exploit which at one time would result in root access. The original default RedHat configuration (6.2) ran the named process as root, thus if an exploit was found, the named process will allow the hacker to use the privileges of the root user. (no longer true)

Named Command Sytax:

   named -u user -g group -t directory-to-chroot-to
          
Example:
    named -u named -g named -t /opt/named

When chrooted, the process does not have access to system libraries thus a local lib directory is required with the appropriate library files - theoretically. This does not seem to be the case here and as noted above in chrooted FTP. It's a mystery to me but it works???? Another method to handle libraries is to re-compile the named binary with everything statically linked. Add -static to the compile options. The chrooted process should also require a local /etc/named.conf etc... but doesn't seem to???

Script to create a chrooted bind environment:


#!/bin/sh
cd /opt
mkdir named
cd named
mkdir etc
mkdir bin
mkdir var
cd var
mkdir named
mkdir run
cd ..
chown -R named.named bin etc var

                    
You can probably stop here. If your system acts like a chrooted system should, then continue with the following:

cp -p /etc/named.conf etc
cp -p /etc/localtime  etc
cp -p /bin/false bin
echo "named:x:25:25:Named:/var/named:/bin/false" > etc/passwd
echo "named:x:25:" > etc/group
touch  var/run/named.pid 

if [ -f /etc/namedb ]
then
   cp -p /etc/namedb etc/namedb
fi

mkdir dev
cd dev

# Create a character unbuffered file.
mknod -m ugo+rw null c 1 3     

cd ..
chown -R named.named bin etc var

                    

Add changes to the init script: /etc/rc.d/init.d/named

#!/bin/bash
#
# named           This shell script takes care of starting and stopping
#                 named (BIND DNS server).
#
# chkconfig: - 55 45
# description: named (BIND) is a Domain Name Server (DNS) \
# that is used to resolve host names to IP addresses.
# probe: true

# Source function library.
. /etc/rc.d/init.d/functions

# Source networking configuration.
. /etc/sysconfig/network

# Check that networking is up.
[ ${NETWORKING} = "no" ] && exit 0

[ -f /etc/sysconfig/named ] && . /etc/sysconfig/named  - Added in Red Hat version 7.1

[ -f /usr/sbin/named ] || exit 0

[ -f /etc/named.conf ] || exit 0

RETVAL=0

start() {
        # Start daemons.
        echo -n "Starting named: "
        daemon named -u named -g named -t /opt/named   - Change made here
	RETVAL=$?
 	[ $RETVAL -eq 0 ] && touch /var/lock/subsys/named
	echo
	return $RETVAL
}
stop() {
        # Stop daemons.
        echo -n "Shutting down named: "
        killproc named
	RETVAL=$?
	[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/named
        echo
	return $RETVAL
}
rhstatus() {
	/usr/sbin/ndc status
	return $?
}	
restart() {
	stop
	start
}	
reload() {
	/usr/sbin/ndc reload
	return $?
}
probe() {
	# named knows how to reload intelligently; we don't want linuxconf
	# to offer to restart every time
	/usr/sbin/ndc reload >/dev/null 2>&1 || echo start
	return $?
}  

# See how we were called.
case "$1" in
	start)
		start
		;;
	stop)
		stop
		;;
	status)
		rhstatus
		;;
	restart)
		restart
		;;
	condrestart)
		[ -f /var/lock/subsys/named ] && restart || :
		;;
	reload)
		reload
		;;
	probe)
		probe
		;;
	*)
        	echo "Usage: named {start|stop|status|restart|condrestart|reload|probe}"
		exit 1
esac

exit $?

                    

Note: The current version of bind from the RedHat errata updates and security fixes (http://www.redhat.com/support/errata/) runs the named process as user "named" in the home (not chrooted) directory /var/named with no shell available. (named -u named) This should be secure enough. Proceed with a chrooted installation if your are paranoid.

See:


Chrooted DNS configuration:

Modern releases of Linux (i.e. Fedore Core 3, Red Hat Enterprise Linux 4) come preconfigured to use "chrooted" bind. This security feature forces even an exploited version of bind to only operate within the "chrooted" jail /var/named/chroot which contains the familiar directories:

  • /var/named/chroot/etc: Configuration files
  • /var/named/chroot/dev: devices used by bind:
    • /dev/null
    • /dev/random
    • /dev/zero
    (Real devices created with the mknod command.)
  • /var/named/chroot/var: Zone files and configuration information.

These directories are generated and configured by the Red Hat/Fedora RPM package "bind-chroot".

If building from source you will have to generate this configuration manually:

  • mkdir -p /var/named/chroot
  • mkdir /var/named/chroot/dev
  • mknod /var/named/chroot/dev/null c 1 3
  • mknod /var/named/chroot/dev/zero c 1 5
  • mknod /var/named/chroot/dev/random c 1 8
  • chmod 666 -R /var/named/chroot/dev
  • mkdir -p /var/named/chroot/etc
  • ln -s /var/named/chroot/etc/named.conf /etc/named.conf
  • mkdir -p /var/named/chroot/var/named
  • ln -s /var/named/chroot/var/named/named.XXXX /var/named/named.XXXX
  • ln -s /var/named/chroot/var/named/named.YYYY /var/named/named.YYYY
  • ...
  • mkdir -p /var/named/chroot/var/named/slaves
  • mkdir -p /var/named/chroot/var/named/data
  • mkdir -p /var/named/chroot/var/run
  • mkdir -p /var/named/chroot/var/tmp
  • chown -R named:named /var/named/chroot
  • chown -R root:named /var/named/chroot/var/named


Load Balancing of servers using Bind: DNS Round-Robin

This will populate name servers around the world with different IP addresses for your web server www.your-domain.com

            www0   IN  A       XXX.XXX.XXX.1
            www1   IN  A       XXX.XXX.XXX.2
            www2   IN  A       XXX.XXX.XXX.3
            www3   IN  A       XXX.XXX.XXX.4
            www4   IN  A       XXX.XXX.XXX.5
            www5   IN  A       XXX.XXX.XXX.6

            www    IN  CNAME   www0.your-domain.com.
IN CNAME www1.your-domain.com.
IN CNAME www2.your-domain.com.
IN CNAME www3.your-domain.com.
IN CNAME www4.your-domain.com.
IN CNAME www5.your-domain.com.
IN CNAME www6.your-domain.com.

Also see lbnamed: lbnamed load balancing named


Bind/DNS Links:

Domain name registration:

Note that the Name registrations policies for the registrars are stated at ICANN.org.

  • You must renew with the same registrar within five days BEFORE the expiration date. There is no rule for afterwards.
  • Most free a domain name 30 days after it expires.
2010. 4. 28. 16:15

vsFTPd and FTP user account configuration


The vsFTPd ftp server was first made available in Red Hat 9.0. It has been adopted by Suse and OpenBSD as well. This is currently the recomended FTP daemon for use on FTP servers.

Enable vsftpd:

  • Red Hat/Fedora Core/CentOS: VsFTPd is a stand alone service and by the default Fedora Core installation, not controlled by xinetd as is the wu-ftpd default installation.
    Thus start service: service vsftpd start (or: /etc/init.d/vsftpd start)
    Configure vsftpd to start upon system boot: chkconfig --add vsftpd

  • SuSE: By default, the vsftpd is an xinetd controlled service. To enable FTP server services edit the file /etc/xinetd.d/vsftpd and change:
    disable = yes
    to:
    disable = no
    Restart the xinetd daemon: /etc/init.d/xinetd restart
    Note: vsftpd can also be run as a stand-alone service to achieve a faster response time.

  • Ubuntu (dapper/hardy) / Debian:
    • Install: apt-get install vsftpd
    • VsFTPd is a stand alone service.
      • Start: /etc/init.d/vsftpd start
      • Stop: /etc/init.d/vsftpd stop
      • Restart: /etc/init.d/vsftpd restart
        (Use this command after making configuration file changes)

For more on starting/stopping/configuring Linux services

Configuration files:

  • vsFTPd configuration file:
    • Fedora Core / Red Hat: /etc/vsftpd/vsftpd.conf
    • S.u.S.e. / Ubuntu (dapper/hardy) / Debian: /etc/vsftpd.conf
    Default for Fedora Core 3:
    anonymous_enable=YES            - Anonymous FTP allowed by default if you comment this out. Default directory used: /var/ftp
    
    local_enable=YES                - Uncomment this to allow local users to log in with FTP.
                                      Must also set SELinux boolean: setsebool -P ftp_home_dir 1
    
    write_enable=YES                - Uncomment this to enable any form of FTP write or upload command.
    
    local_umask=022                 - Default is 077. Umask 022 is used by most other ftpd's.
    
    #anon_upload_enable=YES         - Uncomment to allow the anonymous FTP user to upload files. 
    Requires the above global write enabled. Directory must also be writable by user.
    #anon_mkdir_write_enable=YES - Uncomment this to allow the anonymous FTP user to be able to create new directories. dirmessage_enable=YES - Activate directory messages.
    Messages given to remote users when they enter certain directories
    xferlog_enable=YES - Activate logging of uploads/downloads. connect_from_port_20=YES - PORT transfer connections originate from port 20 (ftp-data) #chown_uploads=YES - Uploaded anonymous files set to a specified owner. (not root) #chown_username=whoever #xferlog_file=/var/log/vsftpd.log - Specify logfile explicitly. Default is /var/log/vsftpd.log xferlog_std_format=YES - Output to log file in standard ftpd xferlog format #idle_session_timeout=600 - Set timing out for an idle session. #data_connection_timeout=120 - Set timing out for an idle data connection. Port 20 #nopriv_user=ftpsecure - Run ftp server as an isolated and unprivileged user. # Enable this and the server will recognise asynchronous ABOR requests. Not # recommended for security (the code is non-trivial). Not enabling it, may confuse older FTP clients. #async_abor_enable=YES #ascii_upload_enable=YES - Improve performance by disabling ASCII mode. Disables command "ascii" and "SIZE /big/file". #ascii_download_enable=YES #ftpd_banner=Welcome to YoLinux - Customize the login banner string. #deny_email_enable=YES - Disallow specified anonymous e-mail addresses. Used to combat certain DoS attacks. #banned_email_file=/etc/vsftpd.banned_emails (Ubuntu default. Red Hat: /etc/vsftpd/banned_emails) #chroot_list_enable=YES - List users chroot()'d to their home directory. If "NO", list users not chroot()'d. #chroot_list_file=/etc/vsftpd.chroot_list (Ubuntu default. Red Hat: /etc/vsftpd/chroot_list) ls_recurse_enable=YES - Allow "ls -R" recursive directory list. Default is disabled. pam_service_name=vsftpd userlist_enable=YES - (Ubuntu Default) Deny users specified in file /etc/vsftpd.user_list If "userlist_enable=NO" then allow specified users. Red Hat: /etc/vsftpd/user_list #deny_email_enable=YES - Disallow specified anonymous e-mail addresses. Used to combat certain DoS attacks. listen=YES - Enable for standalone mode as opposed to an xinetd service. Must set SELinux boolean: setsebool -P ftpd_is_daemon 1 tcp_wrappers=YES
    Restart the FTP service if the config file is changed: service vsftpd restart (or: /etc/init.d/vsftpd restart)

    [Potential Pitfall]: vsftp does NOT support comments on the same line as a directive. i.e.:

    directive=XXX # comment

    vsftp.conf man page

  • Specify list of local users chrooted to their home directories:
    • Red Hat: /etc/vsftpd/vsftpd/chroot_list
    • Ubuntu: /etc/vsftpd/vsftpd.chroot_list
    (Requires: chroot_list_enable=YES)
    user1
    user2
    ...
    user-n
    If userlist_enable=NO, then specify users not to be chroot'd..

  • Specify list of users:
    • Red Hat: /etc/vsftpd/user_list
    • Ubuntu: /etc/vsftpd.user_list
    (Deny list of users requires: userlist_enable=YES)
    Also see PAM configuration below.
    root
    bin
    daemon
    adm
    lp
    sync
    shutdown
    halt
    ...
    If userlist_enable=NO, then specify valid users.

  • PAM configuration file Fedora Core 3: /etc/pam.d/vsftpd
    #%PAM-1.0
    auth       required     pam_listfile.so item=user sense=deny file=/etc/vsftpd.ftpusers onerr=succeed
    auth       required     pam_stack.so service=system-auth
    auth       required     pam_shells.so
    account    required     pam_stack.so service=system-auth
    session    required     pam_stack.so service=system-auth
        
    This causes PAM to check /etc/vsftpd.ftpusers for users who are denied. This duplicates /etc/vsftpd.user_list. Speciy user in both files as PAM is independent of vsftpd configuration.

    PAM authentication configuration file: ftpusers
    • Red Hat: /etc/vsftpd/ftpusers
    • Ubuntu: /etc/vsftpd.ftpusers
    root
    bin
    daemon
    adm
    lp
    sync
    shutdown
    halt
    ...
    ...
    ...
    user6     - Users to deny
    user8
    ...
    ...
        

  • Logrotate configuration file: /etc/logrotate.d/vsftpd.log
    /var/log/xferlog {
        # ftpd doesn't handle SIGHUP properly
        nocompress
        missingok
    }
        

Sample vsFTPd configurations:

  • Anonymous download FTP server configuration: /etc/vsftpd/vsftpd.conf
    # Access rights
    anonymous_enable=YES          - Turn on anonymous FTP
    chown_uploads=YES             - Uploaded files owned by an assigned user
    chown_username=ftp            - Uploaded files owned by this assigned user
    local_enable=NO
    write_enable=NO               - No upload of files system changes allowed
    anon_upload_enable=NO
    anon_mkdir_write_enable=NO
    anon_other_write_enable=NO
    # Security
    anon_world_readable_only=YES
    connect_from_port_20=YES
    force_dot_files=NO
    guest_enable=NO
    hide_ids=YES
    pasv_min_port=50000
    pasv_max_port=60000
    # Features
    xferlog_enable=YES
    ls_recurse_enable=NO
    ascii_download_enable=NO
    async_abor_enable=YES
    # Performance
    one_process_model=NO
    idle_session_timeout=120
    data_connection_timeout=300
    accept_timeout=60
    connect_timeout=60
    max_per_ip=4
    anon_max_rate=50000
    
    pam_service_name=vsftpd
    userlist_enable=YES
    #enable for standalone mode
    listen=YES
    tcp_wrappers=YES
    
    Anonymous logins use the login name "anonymous" and then the user supplies their email address as a password. Any password will be accepted. Used to allow the public to download files from an ftp server. Generally, no upload is permitted.

  • Web hosting configuration: /etc/vsftpd/vsftpd.conf
    # Access rights
    anonymous_enable=NO
    local_enable=YES                              - Allow users to ftp to their home directories
    write_enable=YES                              - Allow users to STOR,  DELE, RNFR, RNTO, MKD, RMD, APPE and SITE
    local_umask=022
    # Security
    connect_from_port_20=YES
    force_dot_files=NO
    guest_enable=NO                               - Don't remap user name
    ftpd_banner=Welcome to Super Duper Hosting    - Customize the login banner string.
    chroot_local_user=YES                         - Limit user to browse their own directory only
    chroot_list_enable=YES                        - Enable list of system / power users
    chroot_list_file=/etc/vsftpd.chroot_list      - Actual list of system / power users
    hide_ids=YES
    pasv_min_port=50000
    pasv_max_port=60000
    # Features
    xferlog_enable=YES
    ls_recurse_enable=NO
    ascii_download_enable=NO
    async_abor_enable=YES
    dirmessage_enable=YES                         - Message greeting held in file .message or specify with message_file=...
    # Performance
    one_process_model=NO
    idle_session_timeout=120
    data_connection_timeout=300
    accept_timeout=60
    connect_timeout=60
    max_per_ip=4
    #
    pam_service_name=vsftpd
    userlist_enable=YES
    #enable for standalone mode
    listen=YES
    tcp_wrappers=YES
    

    Specify list of local users chrooted to their home directories: /etc/vsftpd/vsftpd.chroot_list
    Ubuntu typically: /etc/vsftpd.chroot_list
    (Requires: chroot_list_enable=YES)

    user1
    user2
    ...
    user-n
    If userlist_enable=NO, then specify users not to be chroot'd..

[Potential Pitfall]: Mispelling a directive will cause vsftpd to fail with little warning.

File: .message

A NOTE TO USERS UPLOADING FILES:
   File names may consist of letters (a-z, A-Z), numbers (0-9),
   an under score ("_"), dash ("-") or period (".") only.
   The file name may not begin with a period or dash.

Test if vsftp is listening: netstat -a | grep ftp

[root]# netstat -a | grep ftp
tcp 0 0 *:ftp *:* LISTEN

Links:

2010. 4. 28. 16:13

Apache HTTP Web server configuration


This tutorial is for the Apache HTTP web server (Version 1.3 and 2.0).
The Apache web server configuration file is: /etc/httpd/conf/httpd.conf

Web pages are served from the directory as configured by the DocumentRoot directive. The default directory location is:

Linux distribution Apache web server "DocumentRoot"
Red Hat 7.x-9, Fedora Core, Red Hat Enterprise 4/5, CentOS 4/5 /var/www/html/
Red Hat 6.x and older /home/httpd/html/
Suse 9.x /srv/www/htdocs/
Ubuntu (dapper 6.06/hardy 8.04) / Debian /var/www/html
The default home page for the default configuration is index.html. Note the pages should not be owned by user apache as this is the process owner of the httpd web server daemon. If the web server process is comprimised, it should not be allowed to alter the files. The files should of course be readable by user apache.

Apache may be configured to run as a host for one web site in this fashion or it may be configured to serve for multiple domains. Serving for multiple domains may be achieved in two ways:

  • Virtual hosts: One IP address but multiple domains - "Name based" virtual hosting.
  • Multiple IP based virtual hosts: One IP address for each domain - "IP based" virtual hosting.
The default configuration will allow one to have multiple user accounts under one domain by using a reference to the user account: http://www.domain.com/~user1/. If no domain is registered or configured, the IP address may also be used: http://XXX.XXX.XXX.XXX/~user1/.

[Potential Pitfall] The default umask for directory creation is correct by default but if not use: chmod 755 /home/user1/public_html

[Potential Pitfall] When creating new "Directory" configuration directives, I found that placing them by the existing "Directory" directives to be a bad idea. It would not use the .htaccess file. This was because the statement defining the use of the .htaccess file was after the "Directory" statement. Previously in RH 6.x the files were separated and the order was defined a little different. I now place new "Directory" statements near the end of the file just before the "VirtualHost" statements.

For users of Red Hat 7.1, the GUI configuration tool apacheconf was introduced for the crowd who like to use pretty point and click tools.

Files used by Apache:

  • Start/stop/restart script:
    • Red Hat/Fedora/CentOS: /etc/rc.d/init.d/httpd
    • SuSE 9.3: /etc/init.d/apache2
    • Ubuntu (dapper 6.06/hardy 8.04) / Debian: /etc/init.d/apache2
  • Apache main configuration file:
    • Red Hat/Fedora/CentOS: /etc/httpd/conf/httpd.conf
    • SuSE: /etc/apache2/httpd.conf
      (Need to add directive: ServerName host-name)
    • Ubuntu (dapper 6.06/hardy 8.04) / Debian: /etc/apache2/apache2.conf
  • Apache suplementary configuration files:
    • Red Hat/Fedora/CentOS: /etc/httpd/conf.d/component.conf
    • SuSE: /etc/apache2/conf.d/component.conf
    • Ubuntu (dapper 6.06/hardy 8.04) / Debian:
      • Virtual domains: /etc/apache2/sites-enabled/domain
        (Create soft link from /etc/apache2/sites-enabled/domain to /etc/apache2/sites-available/domain to turn on. Use command a2ensite)
      • Additional configuration directives: /etc/apache2/conf.d/
      • Modules to load: /etc/apache2/mods-available/
        (Soft link to /etc/apache2/mods-enabled/ to turn on)
      • Ports to listen to: /etc/apache2/ports.conf
  • /var/log/httpd/access_log and error_log - Red Hat/Fedora Core Apache log files
    (Suse: /var/log/apache2/)

Start/Stop/Restart scripts: The script is to be run with the qualifiers start, stop, restart or status.
i.e. /etc/rc.d/init.d/httpd restart. A restart allows the web server to start again and read the configuration files to pick up any changes. To have this script invoked upon system boot issue the command chkconfig --add httpd.

Also Apache control tool: /usr/sbin/apachectl start

Apache Control Command: apachectl:

Red Hat / Fedora Core / CentOS: apachectl directive
Ubuntu dapper 6.06 / hardy 8.04 / Debian: apache2ctl directive
Directive Description
start Start the Apache httpd daemon. Gives an error if it is already running.
stop Stops the Apache httpd daemon.
graceful Gracefully restarts the Apache httpd daemon. If the daemon is not running, it is started. This differs from a normal restart in that currently open connections are not aborted.
restart Restarts the Apache httpd daemon. If the daemon is not running, it is started. This command automatically checks the configuration files as in configtest before initiating the restart to make sure the daemon doesn't die.
status Displays a brief status report.
fullstatus Displays a full status report from mod_status. Requires mod_status enabled on your server and a text-based browser such as lynx available on your system. The URL used to access the status report can be set by editing the STATUSURL variable in the script.
configtest
-t
Run a configuration file syntax test.

Apache Configuration Files:

  • /etc/httpd/conf/httpd.conf: is used to configure Apache. In the past it was broken down into three files. These may now be all concatenated into one file. See Apache online documentation for the full manual.
  • /etc/httpd/conf.d/application.conf: All configuration files in this directory are included during Apache start-up. Used to store application specific configurations.
  • /etc/sysconfig/httpd: Holds environment variables used when starting Apache.

Basic settings: Change the default value for ServerName www.<your-domain.com>

Giving Apache access to the file system: It is prudent to limit Apache's view of the file system to only those directories necessary. This is done with the directory statement. Start by denying access to everything, then grant access to the necessary directories.

Deny access completely to file system root ("/") as the default:

Deny first, then grant permissions:
   
<Directory />
   Options None
   AllowOverride None
</Directory>

Set default location of system web pages and allow access: (Red Hat/Fedora/CentOS)
   
DocumentRoot "/var/www/html"

<Directory "/var/www/html">
   Options Indexes FollowSymLinks
   AllowOverride None
   Order allow,deny
   Allow from all
</Directory>

Grant access to a user's web directory: public_html

  • Enabling Red Hat / Fedora Linux, Apache public_html user directory access:

    This will allow users to serve content from their home directories under the subdirectory "/home/userid/public_html/" by accessing the URL http://hostname/~userid/

    File: /etc/httpd/conf/httpd.conf
    LoadModule userdir_module modules/mod_userdir.so
    
    ...
    ...
    
    <IfModule mod_userdir.c>
        #UserDir disable             - Add comment to this line
        #
        # To enable requests to /~user/ to serve the user's public_html
        # directory, remove the "UserDir disable" line above, and uncomment
        # the following line instead:
        UserDir public_html          # Uncomment this line
    </IfModule>
    
    ...
    ...
    
    <Directory /home/*/public_html>
        AllowOverride FileInfo AuthConfig Limit
        Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
        <Limit GET POST OPTIONS>
            Order allow,deny
            Allow from all
        </Limit>
        <LimitExcept GET POST OPTIONS>
            Order deny,allow
            Deny from all
        </LimitExcept>
    </Directory>
    
    Change to a comment (add "#" at beginning of line) from Fedora Core default UserDir disable and assign the directory public_html as a web server accessible directory.
    OR
    Assign a single user the specific ability to share their directory:
     <Directory /home/user1/public_html>
       AllowOverride None
       order allow,deny
       allow from all
       Options Indexes Includes FollowSymLinks
    </Directory>
    
    Allows the specific user, "user1" only, the ability to serve the directory /home/user1/public_html/
    Also use SELinux command to set the security context: setsebool httpd_enable_homedirs true

    Directory permissions: The Apache web server daemon must be able to read your web pages in order to feed their contents to the network. Use an appropriate umask and file protection. Allow access to web directory: chmod ugo+rx -R public_html.
    Note that the user's directory also has to have the appropriate permissions as it is the parent of public_html.
    Default permissions on user directory: ls -l /home
    drwx------ 20 user1 user1 4096 Mar 5 12:16 user1
    Allow the web server access to operate the parent directory: chmod ugo+x /home/user1
    d-wx--x--x 20 user1 user1 4096 Mar 5 12:16 user1

    One may also use groups to control permisions.

  • Enabling Ubuntu's Apache public_html user directory access:

    Ubuntu has broken out the Apache loadable module directives into the directory /etc/apache2/mods-available/. To enable an Apache module, generate soft links to the directory /etc/apache2/sites-enabled/ by using the commands a2enmod/a2dismod to enable/disable Apache modules.

    Example:
    • [root@node2]# a2enmod
      A list of available modules is displayed. Enter "userdir" as the module to enable.
    • Restart Apache with the following command: /etc/init.d/apache2 force-reload

    Note: This is the same as manually generating the following two soft links:

    • ln -s /etc/apache2/mods-available/userdir.conf /etc/apache2/mods-enabled/userdir.conf
    • ln -s /etc/apache2/mods-available/userdir.load /etc/apache2/mods-enabled/userdir.load
    Man page: a2enmod/a2dismod

    [Potential Pitfall]: If the Apache web server can not access the file you will get the error "403 Forbidden" "You don't have permission to access file-name on this server." Note the default permissions on a user directory when first created with "useradd" are:

    drwx------ 3 userx userx
    You must allow the web server running as user "apache" to access the directory if it is to display pages held there.
    Fix with command: chmod ugo+rx /home/userx
    drwxr-xr-x 3 userx userx

SELinux security contexts:

Fedora Core 3 and Red Hat Enterprise Linux 4 introduced SELinux (Security Enhanced Linux) security policies and context labels.
To view the security context labels applied to your web page files use the command: ls -Z

The system enables/disables SELinux policies in the file /etc/selinux/config
SELinux can be turned off by setting the directive SELINUX. (Then reboot the system):

SELINUX=disabled
or using the command setenforce 0 to temporarily disable SELinux until the next reboot.

When using SELinux security features, the security context labels must be added so that Apache can read your files. The default security context label used is inherited from the directory for newly created files. Thus a copy (cp) must be used and not a move (mv) when placing files in the content directory. Move does not create a new file and thus the file does not recieve the directory security context label. The context labels used for the default Apache directories can be viewed with the command: ls -Z /var/www
The web directories of users (i.e. public_html) should be set with the appropriate context label (httpd_sys_content_t).

Assign a security context for web pages: chcon -R -h -t httpd_sys_content_t /home/user1/public_html
Options:

  • -R: Recursive. Files and directories in current directory and all subdirectories.
  • -h: Affect symbolic links.
  • -t: Specify type of security context.

Use the following security contexts:

Context Type Description
httpd_sys_content_t Used for static web content. i.e. HTML web pages.
httpd_sys_script_exec_t Use for executable CGI scripts or binary executables.
httpd_sys_script_rw_t CGI is allowed to alter/delete files of this context.
httpd_sys_script_ra_t CGI is allowed to read or append files of this context.
httpd_sys_script_ro_t CGI is allowed to read files and directories of this context.

Set the following options: setsebool httpd-option true
(or set to false)

Policy Description
httpd_enable_cgi Allow httpd cgi support.
httpd_enable_homedirs Allow httpd to read home directories.
httpd_ssi_exec Allow httpd to run SSI executables in the same domain as system CGI scripts.
Then restart Apache:
  • Red Hat/Fedora/Suse and all System V init script based Linux systems: /etc/init.d/httpd restart
  • Red Hat/Fedora: service httpd restart

The default SE boolean values are specified in the file: /etc/selinux/targeted/booleans  

Virtual Hosts:

The Apache web server allows one to configure a single computer to represent multiple websites as if they were on separate hosts. There are two methods available and we describe the configuration of each. Choose one method for your domain:
  • Name based virtual host: (most common) A single computer with a single IP adress supporting multiple web domains. The web browser using the http protocol, identifies the domain being addressed.
  • IP based virtual host: The virtual hosts can be configured as a single multi-homed computer with multiple IP addresses on a single network card, with each IP address representing a different web domain. This has the appearance of a web domain supported by a dedicated computer because it has a dedicated IP address.

Configuring a "name based" virtual host:

A virtual host configuration allows one to host multiple web site domains on one server. (This is not required for a dedicated linux server which hosts a single web site.)

NameVirtualHost XXX.XXX.XXX.XXX

<VirtualHost XXX.XXX.XXX.XXX>
ServerName www.your-domain.com - CNAME (bind DNS alias www) specified in Bind configuration file (/var/named/...) ServerAlias your-domain.com - Allows requests by domain name without the "www" prefix. ServerAdmin user1@your-domain.com DocumentRoot /home/user1/public_html
ErrorLog logs/your-domain.com-error_log TransferLog logs/your-domain.com-access_log </VirtualHost>

Notes:

  • You can specify more than one IP address. i.e. if web server is also being used as a firewall/gateway and you have an external internet IP address as well as a local network IP address.
    NameVirtualHost XXX.XXX.XXX.XXX
    NameVirtualHost 192.168.XXX.XXX
    
    <VirtualHost XXX.XXX.XXX.XXX 192.168.XXX.XXX>
       ...
       ..
    
  • Use your IP address for XXX.XXX.XXX.XXX, actual domain name and e-mail address.
    One can use DNS views to provide different local network DNS results.

  • Note that I configure Apache for both requests http://www.domain-name.com and http://domain-name.com.

  • Once virtual hosts are configured, your default system domain (/var/www/html) will stop working. Your default domain now must be configured as a virtual domain.
    <Directory "/var/www/html">
    
       ...  This part remains the same
       ..
    
    </Directory>
    
    # Default for when no domain name is given (i.e. access by IP address)
    
    <VirtualHost *:80>
       ServerAdmin user1@your-domain.com
       DocumentRoot /var/www/html
       ErrorLog logs/error_log
       TransferLog logs/access_log
    </VirtualHost>
    
    # Add a VirtualHost definition for your domain which was once the system default.
    
    <VirtualHost XXX.XXX.XXX.XXX>
    ServerName www.your-domain.com ServerAlias your-domain.com ServerAdmin user1@your-domain.com DocumentRoot /var/www/html ErrorLog logs/error_log TransferLog logs/access_log </VirtualHost> ... ..

  • Forwarding to a primary URL. It is best to avoid the appearance of duplicated web content from two URLs such as http://www.your-domain.com and http://your-domain.com. Supply a forwarding Apache "Redirect".
    <VirtualHost XXX.XXX.XXX.XXX>
       ServerName www.your-domain.com   - Note that no aliases are listed
       ...
       ...
    </VirtualHost>
    
    # Add a VirtualHost definition to forward to your primary URL
    
    <VirtualHost XXX.XXX.XXX.XXX>
       ServerName your-domain.com
       ServerAlias other-domain.com
       ServerAlias www.other-domain.com
       Redirect permanent / http://www.your-domain.com.com/
    </VirtualHost>
    
       ...
       ..
        

  • More virtual host examples.

When specifying more domains, they may all use the same IP address or some/all may use their own unique IP address. Specify a "NameVirtualHost" for each IP address.

After the Apache configuration files have been edited, restart the httpd daemon: /etc/rc.d/init.d/httpd restart (Red Hat) or /etc/init.d/apache2 restart (Ubuntu / Debian)

Apache virtual domain configuration with Ubuntu Dapper/Hardy:

Ububntu separates out each virtual domain into a separate configuration file held in the directory /etc/apache2/sites-available/. When the site domain is to become active, a soft link is created to the directory /etc/apache2/sites-enabled/.
Example: /etc/apache2/sites-available/supercorp
<VirtualHost XXX.XXX.XXX.XXX>
        ServerName supercorp.com
        ServerAlias www.supercorp.com
        ServerAdmin webmaster@localhost

        DocumentRoot /home/supercorp/public_html/home
        <Directory "/">
                Options FollowSymLinks
                AllowOverride None
        </Directory>
        <Directory /home/supercorp/public_html/home>
                Options Indexes FollowSymLinks MultiViews
                IndexOptions SuppressLastModified SuppressDescription
                AllowOverride All
                Order allow,deny
                allow from all
        </Directory>

        ScriptAlias /cgi-bin/ /home/supercorp/cgi-bin/
        <Directory "/home/supercorp/cgi-bin/">
                AllowOverride None
                Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
                Order allow,deny
                Allow from all
        </Directory>

        ErrorLog /var/log/apache2/supercorp.com-error.log

        # Possible values include: debug, info, notice, warn, error,
        # crit, alert, emerg.
        LogLevel warn
        CustomLog /var/log/apache2/supercorp.com-access.log combined
        ServerSignature On
</VirtualHost>
Enable domain:
  • Create soft link:
    • Manually: ln -s /etc/apache2/sites-available/supercorp /etc/apache2/sites-enabled/supercorp
    • Use Ubuntu scripts a2ensite/a2dissite. Type command and it will prompt you as to which site you would like to enable or disable.
  • Restart Apache:
    • apache2ctl graceful
      or
    • /etc/init.d/apache2 restart
      or
    • /etc/init.d/apache2 reload
Also note that Apache modules can also be enabled/disabled with scripts a2enmod/a2dismod.

Man pages:

  • a2ensite/a2dissite (Ubuntu: Apache 2 enable/disable site)
  • apache2ctl

Configuring an "IP based" virtual host:

One may assign multiple IP addresse to a single network interface. Each IP address may then be it's own virtual server and individual domain. The downside of the "IP based" virtual host method is that you have to possess multiple/extra IP addresses. This usually costs more. The standard name based virtual hosting method above is more popular for this reason.
   
NameVirtualHost *              - Indicates all IP addresses

<VirtualHost *>
   ServerAdmin user0@default-domain.com
   DocumentRoot /home/user0/public_html
</VirtualHost>

<VirtualHost XXX.XXX.XXX.101>
   ServerAdmin user1@domain-1.com
   DocumentRoot /home/user1/public_html
</VirtualHost>

<VirtualHost XXX.XXX.XXX.102>
   ServerAdmin user1@domain-2.com
   DocumentRoot /home/user2/public_html
</VirtualHost>
The default <VirtualHost *> block will be used as the default for all IP addresses not specified explicitly. This default IP (*) may not work for https URL's.

CGI: (Common Gateway Interface)

CGI is a program executable which dynamically generates a web page by writing to stdout. CGI is permitted by either of two configuration file directives:
  • ScriptAlias:
    • Red Hat 7.x-9, Fedora core: ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
    • Red Hat 6.x and older: ScriptAlias /cgi-bin/ "/home/httpd/cgi-bin/"
    • Suse 9.x: ScriptAlias /cgi-bin/ "/srv/www/cgi-bin/"
    • Ubuntu (dapper/hardy) / Debian: ScriptAlias /cgi-bin/ "/usr/lib/cgi-bin/"
    or
  • Options +ExecCGI:
    <Directory /var/www/cgi-bin>
    Options +ExecCGI
    </Directory>
The executable program files must have execute privileges, executable by the process owner (Red Hat 7+/Fedora Core: apache. Older use nobody) under which the httpd daemon is being run.

Configuring CGI To Run With User Privileges:

The suEXEC feature provides Apache users the ability to run CGI and SSI programs under user IDs different from the user ID of the calling web-server. Normally, when a CGI or SSI program executes, it runs as the same user who is running the web server.
NameVirtualHost XXX.XXX.XXX.XXX

<VirtualHost XXX.XXX.XXX.XXX>
   ServerName node1.your-domain.com                         - Allows requests by domain name without the "www" prefix.
   ServerAlias your-domain.com www.your-domain.com          - CNAME (alias www) specified in Bind configuration file (/var/named/...)
   ServerAdmin user1@your-domain.com
   DocumentRoot /home/user1/public_html/your-domain.com
   ErrorLog logs/your-domain.com-error_log
   TransferLog logs/your-domain.com-access_log
  
   SuexecUserGroup user1 user1
   <Directory /home/user1/public_html/your-domain.com/>
      Options +ExecCGI +Indexes
      AddHandler cgi-script .cgi
   </Directory>
</VirtualHost>

ERROR Pages:

You can specify your own web pages instead of the default Apache error pages:

   ErrorDocument 404 /Error404-missing.html
Create the file Error404-missing.html in your "DocumentRoot" directory.

PHP:

If the appropriate php, perl and httpd RPM's are installed, the default Red Hat Apache configuration and modules will support PHP content. RPM Packages (RHEL4):

  • php: HTML-embedded scripting language
  • php-pear: PEAR is a framework and distribution system for reusable PHP components.
  • php-mysql: MySQL database support.
  • php-ldap: Lightweight Directory Access Protocol (LDAP) support

Apache configuration:

Add php default page index.php to apache config file: /etc/httpd/conf/httpd.conf
...

DirectoryIndex index.html index.htm index.php

...
PHP Configuration File:
  • RHEL4 - PHP 4.3: /etc/php.ini
  • Ubuntu Daper 6.06/6.11: /etc/php5/apache2/php.ini
[PHP]
engine = On
...
...
display_errors = Off
include_path = ".:/php/includes"
...
...
memory_limit = 32M   ; Default is typically 8MB which is too low.
...
...

[MySQL]
...
...
mysql.default_host = superserver    ; Hostname of the computer
mysql.default_user = dbuser
...
Small portion of file shown.
Note that changes will not take effect until the apache web server daemon is restarted.

Test you PHP capabilities with this test file: /home/user1/public_html/test.php

<?php
phpinfo();
?>
OR (older format)
<?
   phpinfo();
?>
Test: http://localhost/~user1/test.php

Running Multiple instances of httpd:

The Apache web server daemon (httpd) can be started with the command line option "-f" to specify a unique configuration file for each instance. Configure a unique IP address for each instance of Apache.

Apache Man Pages:

  • httpd - Apache Hypertext Transfer Protocol Server
  • apachectl - Apache HTTP Server Control Interface
  • ab - Apache HTTP server benchmarking tool
  • htdigest - manage user files for digest authentication
  • htpasswd - Manage user files for basic authentication
  • logresolve - Resolve IP-addresses to hostnames in Apache log files
  • rotatelogs - Piped logging program to rotate Apache logs


Log file analysis:

Scanning the Apache web log files will not provide meaningfull statistics unless they are graphed or presented in an easy to read fashion. The following packages to a good job of presenting site statistics.

Web site statistic services:

Load testing your server:

Apache Links:


Log file analysis using Analog:

Installation:

  • Red Hat / Fedora: yum install analog
  • Ubuntu / Debian: apt-get install analog
Installation packages also available from the Analog downloads page.

Configuration file: /etc/analog.cfg
LOGFILE /var/log/httpd/your-domain.com-access_log* http://www.your-domain.com
UNCOMPRESS *.gz,*.Z "gzip -cd"
SUBTYPE *.gz,*.Z
#
OUTFILE /home/user1/public_html/analog/Report.html
#
HOSTNAME "YourDomain.com"
HOSTURL  http://www.your-domain.com

....
...
..

REQINCLUDE pages                  # Request page stats only
ALL ON
LANGUAGE US-ENGLISH
One can view the settings which be used with your configuration file (also good for debugging): analog -settings

Make Analog images available to the users report: ln -s /usr/share/analog/images/* /home/user1/public_html/analog

Log file location:

  • Red Hat / Fedora: /var/log/httpd/
  • Ubuntu / Debian: /var/log/apache2/
The Directive ALL ON turns on all of the following:
Analog Directive Description
MONTHLY ON one line for each month
WEEKLY ON one line for each week
DAILYREP ON one line for each day
DAILYSUM ON one line for each day of the week
HOURLYREP ON one line for each hour of the day
GENERAL ON the General Summary at the top
REQUEST ON which files were requested
FAILURE ON which files were not found
DIRECTORY ON Directory Report
HOST ON which computers requested files
ORGANISATION ON which organisations they were from
DOMAIN ON which countries they were in
REFERRER ON where people followed links from
FAILREF ON where people followed broken links from
SEARCHQUERY ON the phrases and words they used...
SEARCHWORD ON ...to find you from search engines
BROWSERSUM ON which browser types people were using
OSREP ON and which operating systems
FILETYPE ON types of file requested
SIZE ON sizes of files requested
STATUS ON number of each type of success and failure
Cron job to handle multiple domains: /etc/cron.daily/analog
#!/bin/sh
cp /opt/etc/analog-domain1.com.cfg      /etc/analog.cfg
/usr/bin/analog
cp /opt/etc/analog-domain2.com.cfg      /etc/analog.cfg
/usr/bin/analog

...
Links:
2010. 4. 22. 09:12

vsftpd 설정


출처 : http://community.365managed.com/10759

VSFTP

리눅스에서 사용하는 FTP 서버용 소프트웨어는 proftp, vsftp가 주로 사용됩니다. Proftp에 비해서 속도와 보안, 성능이 뛰어나며 무엇보다 안정성을 보장할 수 있는 프로그램입니다.

 

설정파일경로 : /etc/vsftpd/vsftpd.conf
 
 

① 기본설정 

background=YES (기본값 = NO)

VsFTP 데몬을 background로 실행할 것인지 설정 합니다.

 

listen=YES (기본값 = NO)

VsFTP 데몬은 기본적으로 inetd 모드로 동작이 됩니다.

따라서 독립모드(standalone)로 데몬을 운영하실 거라면 이 옵션과 listen 옵션을 모두 YES로 켜주셔야 됩니다. 반대로 VsFTP 데몬을 inetd 모드로 운영하시려면 이 옵션과 listen 옵션을 비활성화 하시면 됩니다.일반적으로 FTP 데몬은 많은 접속이 있을 경우에 standalone 모드로 운영하는것이 좋으며, 많은 접속이 없는 경우에는 inetd 모드로 운영하는것이 시스템 자원효율에 좋습니다. background 옵션과 같이 사용되며, 이 옵션은 listen_port에서 들어오는 요청에 대해서 데몬이 요청을 받아드릴지에 대해 설정합니다. 만약 데몬을 독립모드(standalone)로 운영하실 거라면 background 옵션과 같이 이 옵션도 함께 활성화 시켜야 됩니다.

listen_port=21

만약 vsftpd를 xinetd모드가 아닌 독립데몬 (standalone)으로 서비스하려면 위의 listen 지시자를 YES로 설정하시고 listen_port 에 서비스할 포트번호(기본 21번)를 지정하시면 됩니다.

 

listen_address=none (기본값 = none)

멀티 FTP 데몬을 사용할 때 요청을 받아드릴 IP를 설정합니다.

 

listen_address6=none (기본값 = none)

listen_address와 동일하며 IPv6에서 운영할 때 사용 합니다.

 

pasv_address=none (기본값 = none)

NAT를 사용하는 클라이언트의 공용 IP를 설정할 때 사용 합니다. 일반적으로 설정하지 않아도 상관 없습니다.

 

nopriv_user=ftpsecure (기본값 = nobody)

VsFTPd가 구동될 서버의 유저를 설정합니다.

 

max_clients=30 (기본값 = 0)

FTP 서버에 접속할 수 있는 클라이언트의 최대수를 제한하는 옵션 입니다. 기본값인 0으로 설정하면 제한을 두지 않습니다.

 

max_per_ip=3

이 설정은 동시 ftp 접속자수를 제한하는 설정입니다. 첫번째 max_client 는 ftp 접속을 최대 30명까지만 허용한다는 설정입니다. 그리고 max_per_ip 는 한 IP(호스트)에서 동시에 3번까지만 접속이 가능하다는 설정입니다. 이 또한 서비스거부공격(DoS)를 방어하기 위한 방법으로 활용될 수 있습니다.

 

local_max_rate=0 (기본값 = 0)

계정 사용자의 최대전송률을 지정합니다.업/다운로드의 속도를 제한할 때 사용하며, 단위는 bps 입니다.

 

trans_chunk_size=0

위의 세가지 설정은 ftp 서비스의 전송속도를 제한 하도록 하는 설정입니다. 즉, 초당 byte 수를 지정할 수 있으며 제한없이 허용하려면 0 으로 설정하시면 됩니다. 이 설정은 vsftpd 가 독립데몬(standalone)모드로 서비스될 때에만 적용되는 것입니다. 

 

use_localtime=YES (기본값 = NO)

서버의 FTP 데몬시간을 서버의 표준시간으로 고정할지 설정합니다.  만약 이 옵션을 비활성화 하게되면 표준시각(GMT)를 보여주므로, 한국의 경우 9시간의 오차가 발생합니다.

 

setproctitle_enable=YES (기본값 = NO)

프로토콜의 현재 상태를 출력해줄 것인지 설정합니다. 이 옵션을 활성화하면 ps 명령어를 사용했을 때 세션의 현재 상태도 보여줍니다. 또한 LTN에서 제공하는 ftpwho 스크립트를 사용할 때에도 이 옵션을 활성화 하셔야 됩니다.

 

user_config_dir=none (기본값 = none)

특정 사용자의 개별 설정 파일을 지정합니다. 이 옵션을 사용하면 /etc/vsftpd/vsftpd.conf의 지시문을 무시하고 사용할 수 있습니다.

 

② 접속설정  

local_enable=YES

로컬 계정 사용자들의 접속을 허용할 것인가의 여부를 결정합니다. YES 로 설정하면 로컬계정사용자의 접속을 허용하는 것이며 NO로 설정하면 허용하지 않는 것입니다. 기본 설정은 YES로 되어있기 때문에 접속을 허용하게 됩니다. 만약 NO로 설정되어 있을 때 로컬 계정으로 접속을 시도하면 “530 This FTP server is anonymous only.”와 같은 에러메시지를 출력하면서 접속을 거부합니다.

 

pam_service_name=vsftpd

vsftpd에서 PAM설정파일명으로 사용할 파일명을 지정합니다. 이 설정이 적용되면 기본이 vsftpd 이므로 /etc/pam.d/vsftpd 파일이 사용됩니다.

 

userlist_enable=YES (기본값 = NO)

명시된 사용자만 로그인을 허용할 때 사용하는 옵션입니다. userlist_deny 옵션이 비활성화 된 상태에서만 작동합니다.

 

userlist_deny=YES (기본값 = YES)

명시된 사용자가 로그인을 할 수 없도록 제한하는 옵션 입니다.

userlist_enable 옵션이 비활성화 된 상태에서만 작동하며, 서로 반대되는 개념 입니다.

 

userlist_file=/etc/vsftpd.user_list (기본값 = /etc/vsftpd.user_list)

명시된 사용자를 읽어올 파일을 지정합니다.

 

text_userdb_names=NO (기본값 = NO)

디렉토리 목록의 사용자와 그룹 필드들에 있는 숫자 ID 들이 보이는 것이 기본값 입니다.

당신은 이 파라미터를 활성화 함으로써 글자 이름을 사용할 수도 있습니다. 그러나 이 항목은 성능상의 이유로 기본적으로 비활성화 되어 있습니다.

 

tcp_wrappers=YES

tcp_wrappers 적용 여부를 설정하는 것으로 사용할 것인가(YES) 사용하지 않을 것인가(NO)를 설정합니다. YES로 설정하시면 허용할 호스트는 /etc/hosts.allow 허용하지 않을 호스트는 /etc/hosts.deny에 설정합니다.

 

ssl_tlsv1=YES (기본값 = YES)

TLS를 사용할 것인지에 대해 설정합니다.

이 옵션은 TLS를 활성화하며, TLS가 가능한 클라이언트가 이용하는데 도움이 됩니다.

 

ssl_enable=NO (기본값 = NO)

SSL을 통한 보안접속을 지원할 것인지에 대해 설정합니다.

만약 OpenSSL에 대해서 컴파일 되어 있고, 이 옵션을 허용할 경우 vsftpd는 SSL을 통한 보안 접속을 지원합니다. 이 옵션은 제어 연결을 지원(로그인을 포함)하며, 또한 데이터 연결도 지원 합니다. 사용자는 SSL을 지원하는 클라이언트를 필요로 할 것이며, 반드시 필요한 경우에만 허용하는것이 좋습니다. 그러나 vsftpd는 OpenSSL 라이브러리의 보안과 관련한 게런티를 만들 수 없으며, 이 옵션을 활성화 합니다는것은 OpenSSL 라이브러리의 보안을 믿는다는 것을 전제로 합니다.

 

ssl_sslv2=NO (기본값 = NO)

SSL v2 프로토콜 연결을 허용할 것인지에 대해 설정합니다.

이 옵션은 ssl_enable이 활성화 되었을 때만 적용되며, TLS v1 연결들을 선호 합니다.

 

ssl_sslv3=NO (기본값 = NO)

SSL v3 프로토콜 연결을 허용할 것인지에 대해 설정합니다.

이 옵션은 ssl_enable이 활성화 되었을 때만 적용되며, TLS v1 연결들을 선호 합니다.

 

listen_ipv6=NO (기본값 = NO)

listen 옵션과 동일하지만, IPv6에서 운영할 때 사용 합니다.  일반적으로 IPv6는 사용하지 않으므로 비활성화 하시면 됩니다.

 

dsa_cert_file=none (기본값 = none)

SSL 인증서의 위치를 지정합니다. SSL의 암호화 접속을 사용하기 위해, DSA 인증서의 위치를 지정합니다.

 

ssl_ciphers=DES-CBC3-SHA (기본값 = DES-CBC3-SHA)

이 옵션은 vsftpd가 암호화 된 SSL 연결들에 대해 어떤 SSL 암호화 방식을 선택하는지에 따라 사용됩니다. 더 자세한 사항은 관련 암호 메뉴얼 페이지를 보십시요.

암호화를 알리지 않는 것은 원격에서 선택된 암호화 방식의 취약점을 공격하려고 불법적인 원격 공격을 막기 위한 유용한 보안 지침이 될 수 있습니다.

 

force_local_data_ssl=YES (기본값 = YES)

이 옵션은 ssl_enable이 활성화 되었을 때만 적용되며, 만약 이 옵션이 활성화 되어 있습니다. 모든 비익명 로그인은 데이터 연결 상태에서 데이터를 주고 받기 위해 보안 SSL 연결을 사용하도록 강제적으로 설정됩니다.

 

force_local_logins_ssl=YES (기본값 = YES)

이 옵션은 ssl_enable이 활성화 되었을 때만 적용되며, 만약 이 옵션이 활성화 되어 있습니다. 모든 비익명 로그인은 비밀번호를 전달하기 위해 보안 SSL 연결을 사용하도록 강제적으로 설정됩니다.

 

③ 대기시간 설정  

connect_timeout=60 (기본값 = 60/초)

액티브 모드(Active Mode)를 사용하는 클라이언트의 접속 허용시간을 설정합니다. 클라이언트의 요청패킷(SYN Packet)을 받은뒤, 지정된 시간내에 접속이 안될경우 종료합니다.

 

accept_timeout=60 (기본값 = 60/초)

패시브 모드(Passive Mode)를 사용하는 클라이언트의 접속 허용시간을 설정합니다. 클라이언트의 요청패킷(SYN Packet)을 받은뒤, 지정된 시간내에 접속이 안될경우 종료합니다.

 

data_connection_timeout=300 (기본값 = 300/Secs)

데이터 전송시 적용되는 타임아웃값을 설정합니다. 만약 ftp 연결시 큰 파일을 업로드 또는 다운로드 할 때에 전송도중 접속이 끊기는 상황이 발생한다면 이 설정을 주석처리하거나 또는 이 값을 현재 설정값 보다 크게 잡아주시고 재시도 해보십시요.

 

idle_session_timeout=300 (기본값 = 300/Secs)

ftp 연결에서 idle 타임에 대한 타임아웃값을 설정합니다. 예를 들어 이 값이 600으로 설정되어 있다면 ftp 접속후에 600초(10분)동안 아무런 작업도 없이 놀고 있다면 강제 로그아웃(timeout)시켜 버립니다.

 

④ 메시지 설정  

banner_file=/etc/vsftpd/welcome.msg (기본값 = none)

사용자가 FTP 서버에 접속했을 때 보여줄 환영 메시지 파일을 설정합니다.

 

ftpd_banner=Welcome to blah FTP service.

ftp 서버로 접속할 때에 안내메시지등을 출력하려면 여기서 설정하시면 됩니다. 이 설정이 적용되면 ftp 접속을 하였을 때 "Welcome to blah FTP service"라는 안내문이 출력됩니다. 이 설정에서 한글을 사용할 수도 있습니다. 각 디렉토리별 안내문에 대한 설정은 다음 지시자의 설명을 보시기 바랍니다.

 

dirmessage_enable=YES

ftp 접속한 사용자가 특정 디렉토리로 이동하였을 때 개별 디렉토리의 메시지를 보여주도록 허용할 것인가(YES) 허용하지 않을 것인가(NO) 를 설정하는 것입니다. 밑에서 설명하고 있는 "message_file" 지시자에서 개별 디렉토리안내 파일로 사용할 파일명을 지정할 수 있습니다.

 

Message_file=.message

ftp 접속후에 특정 디렉토리로 이동할 때에 디렉토리 안내메시지 파일로 사용할 파일명을 지정한 것입니다. 이 설정은 바로 위에서 설명한 "dirmessage_enable" 이 YES로 설정되어 있을 때 적용됩니다.

 

⑤ 모드설정

port_enable=YES (기본값 = YES)

데이터 전송을 위해서 Active Mode를 사용할 것인지 설정합니다.

 

connect_from_port_20=YES

ftp 서비스는 기본적으로 21번 포트와 20번 포트를 사용합니다. ftp 접속과 명령어에 사용되는 포트는 21번이며 실제 데이터전송에 사용되는 기본포트는 20번입니다. 이때 20번 포트의 데이터전송 연결을 허용할 것인가(YES) 허용하지 않을 것인가(NO)를 설정하는 지시자 입니다.

 

ftp_data_port=20 (기본값 = 20)

데이터 전송 포트를 지정합니다.

connect_from_port_20 옵션이 활성화 되었을 때 사용되는 포트를 지정합니다.

 

pasv_enable=YES (기본값 = YES)

데이터 전송을 위해서 Passive mode를 사용할 것인지 설정합니다.

Active Mode로 접근할 수 없는 사용자들을 위해 활성화 하는 것 이 좋습니다.

 

pasv_promiscuous=NO (기본값 = NO)

동일한 IP주소에서 이루어지는 데이터 연결을 보장해주는 보안체크 기능을 사용할 것인지 설정합니다.

 

pasv_min_port=0

pasv_max_port=0 (기본값 = 0)

패시브 모드로 연결시 할당될 최대 및 최소 포트를 설정하는 옵션 입니다. 일반적으로 50000~60000 포트를 지정하는 것이 좋으며, 기본값인 0으로 설정하게 되면 well-known port를 제외한 무작위 포트를 이용하게 됩니다.

 

ascii_upload_enable=YES

ascii_download_enable=YES

기본적으로 ASCII 모드로 업로드/다운로드하는 것이 제한되어 있습니다. 이 설정으로 ASCII모드로의 업로드/다운로드를 허용하도록 설정할 수 있습니다.

 

⑥ 권한설정  

local_umask=022

로컬계정 사용자들의 umask 값을 설정하는 지시자입니다. 거의 모든 ftp 서버에서 기본 umask 값은 022 입니다. 하지만 vsftp 에서의 umask 기본값은 077입니다. Umask 값이 077 일 경우에 새로 생성되는 파일의 퍼미션은 600 이 되며 새로 생성되는 디렉토리의 퍼미션은 700 이 됩니다. 당연히 umask 값이 022 일 때보다는 보안이 훨씬 강화됩니다. 여기서 "local_umask=022"의 주석을 제거하여 유효하게 설정하면 대부분의 FTP 서버에서 사용하는 umask 값을 022로 설정하게 됩니다. 만약 022 외에 다른 umask 값을 설정하고자 한다면 그 값을 설정해 주시면 됩니다.

 

file_open_mode=0644 (기본값 = 0666)

파일이 업로드 되었을 때의 퍼미션을 지정해주는 옵션 입니다.

이 옵션은 반드시 umask 옵션보다 아래에 있어야 됩니다.

 

dirlist_enable=YES (기본값 = YES)

접속한 디렉토리의 파일리스트를 보여줄 지 설정합니다.

 

force_dot_files=NO (기본값 = NO)

히든 파일/디렉토리를 보여줄 것인지 설정하는 옵션 입니다. 히든 파일/디렉토리는 dot(.) 으로 시작하는 것을 말합니다.

 

tilde_user_enable=NO (기본값 = NO)

이 옵션이 활성화되면, vsftpd는 ~chris/pics와 같이 사용자 계정 이름에 틸드 표시가 따라오는 경우의 경로명을 접근하도록 시도하고 해석할 것입니다. vsftpd는 항상 ~ 와 ~/somthing 을 해석합니다는 것을 주의하시기 바랍니다.

(여기서 ~ 는 기본적으로 로그인 했을 때의 디렉토리로 해석됩니다.) ~user 경로들은 _current_ chroot() 에서 /etc/passwd 파일을 찾을 수 있을 경우에만 해석 될 수 있을 것입니다.

 

hide_ids=NO (기본값 = NO)

디렉토리 목록에서 UID를 보여주지 않고, 모두 FTP로 표시할 것인지 설정합니다.

이 옵션을 활성화 하면 모든 파일의 소유권이 FTP로 표시되므로 보안에 도움이 될 수 있습니다.

 

write_enable=YES (기본값 = NO)

ftp 로 접속이 된 상태에서 사용할 수 있는 ftp 전용명령어에는 여러가지가 있습니다. 이 설정은 ftp 전용명령어 중에 write 명령어를 허용할 것인가를 결정하는 것입니다. 허용하려면 YES, 허용하지 않으려면 NO 를 설정하시면 됩니다.

 

download_enable=YES (기본값 = YES)

다운로드에 대한 권한을 설정합니다.

 

chmod_enable=YES (기본값 = YES)

사용자가 퍼미션을 변경할 수 있도록 설정합니다.

 

use_sendfile=YES (기본값 = YES)

이 옵션은 당신의 플랫폼에서 sendfile() 시스템 호출을 사용하는 것과 관련된 이익을 테스트 할 때 사용되는 내부 설정입니다.

 

cmds_allowed=PASV,RETR,QUIT (기본값 = none)

사용자에게 허가할 명령어를 지정합니다.

 

deny_file={*.mp3,*.mov} (기본값 = none)

업로드를 거부할 파일명을 지정합니다.

 

hide_file={*.mp3,*.mov} (기본값 = none)

숨길 파일명을 지정합니다.

이 옵션을 사용하면 서버에 실제로 데이터는 존재하지만, FTP 사용자에게는 보이지 않도록

설정하는 기능입니다. 악의적인 사용자에게 간단한 fake를 걸 수 있습니다.

 

async_abor_enable=YES (기본값 = NO)

async ABOR 명령어를 사용할 수 있도록 설정합니다.

일부 FTP 클라이언트에서 파일전송을 취소했을 경우, 취소되지 않은 상태로 있는 경우가

생길 수 있는데 그것을 방지하기 위해 사용할 수 있습니다.

그러나 보안상 좋지 않기 때문에, 비활성화 하시는것이 좋습니다.

 

ls_recurse_enable=YES

ftp 접속에서는 ls 사용시 –R 옵션을 허요하지 않는 것이 기본 설정입니다. –R 옵션이란 서브디렉토리내의 파일들의 리스팅(목록)까지 모두 확인할 수 있도록 하는 것입니다. 서버부하등의 이유로 ftp에서 기본적으로는 지원하지 않지만 vsftpd 에서는 이 옵션을 사용하여 허용하도록 설정할 수 있습니다. 즉, 이 지시자의 값이 YES로 되어 있다면 ftp 접속후에 디렉토리 목록 확인시에 서브디렉토리들의 목록들까지 한번에 볼 수 있는 –R 옵션을 허용하게 됩니다.

 

⑦ 보안설정

 

chroot_list_enable=YES (기본값 = NO)

명시된 사용자가 자신의 홈상위 디렉토리를 접근할 수 없도록 설정합니다.이 옵션은 chroot_local_user 옵션이 비활성화되어 있어야 사용할 수 있습니다. 전체 적용이 아니라 일부 사용자만 제한할때 편하지만, 개별 적용은 보안상 좋지 않습니다.

 

chroot_list_file=/etc/vsftpd.chroot_list

전체 사용자가 아닌 특정 사용자들에 대하여 자신의 홈디렉토리를 루트디렉토리로 인식하도록 하는 기능으로서 이 기능은 사용자의 홈디렉토리의 상위디렉토리로 벗어나지 못하도록 하는 설정입니다.

먼저 "chroot_list_enable=YES" 로 설정하시고 /etc/vsftpd.chroot_list 파일에는 이 기능을 적용할 사용자계정명을 등록해 두시면 됩니다. 즉, /etc/vsftpd.chroot_list 파일에 등록된 사용자들에 한하여 chroot()기능이 적용되어 자기 자신의 홈디렉토리 상위 디렉토리의 이동이 제한됩니다. 이 파일에 등록할 때에는 한행에 한 사용자 계정씩만 등록하셔야 합니다. 만약 전체 사용자를 대상으로 chroot()기능을 적용하고자 한다면 바로 밑에서 설정하고 있는 "chroot_local_user=YES"로 설정하시기 바랍니다.
 

passwd_chroot_enable=NO (기본값 = NO)

SSH로 접속했을 때 자신의 홈 상위 디렉토리를 접근할 수 없도록 설정합니다.

chroot_local_user 옵션이 활성화되었고, OpenSSH에 패치를 했을경우, SSH 또한 자신의 홈상위 디렉토리를 접근할 수 없도록 설정할 수 있으며, /etc/passwd 파일의 홈 디렉토리 필드의 /home/사용자/./와 같이 "/./"를 붙여 사용자를 홈디렉토리에 제한하게 합니다.

 

chroot_local_user=YES

특정 사용자가 아닌 전체 사용자를 대상으로 chroot()기능을 적용하여 자기 자신의 홈디렉토링 상위 디렉토리로 이동하지 못하도록 하려면 이 설정을 YES로 설정하십시요. 반드시 앞의 설정과 비교해 보시기 바랍니다.

 

만약 위 의 두 설정이 모두 설정되었다면

즉, "chroot_list_enable=YES"와 "chroot_local_user=YES" 설정이 모두 YES로 되어 있다면 /etc/vsftpd.chroot_list 에 등록된 사용자만 chroot()적용을 받지 않게 됩니다. 즉, 이 두 설정이 모두 YES 로 되어 있다면 /etc/vsftpd.chroot_list 에 등록된 사용자들을 제외한 나머지 사용자들만 chroot()가 적용되어 상위 디렉토리로의 이동이 안된다는 의미입니다.

 

secure_chroot_dir=/usr/share/empty (기본값 = /usr/share/empty)

secure chroot()에 사용될 디렉토리를 지정합니다.

이 옵션에서 지정된 디렉토리는 비어있어야되며, ftp 사용자에 대해 쓰기 권한이 없어야 됩니다.

 

⑧ 로그설정

xferlog_enable=YES

ftp 접속후에 파일 업로드와 다운로드에 대한 로그를 남길것인가(YES) 남가지 않을 것인가(NO)를 설정하는 지시자입니다. 이 지시자의 설정은 디스크의 용량을 고려하여 결정해야 합니다. 즉, 파일 업로드/다운로드 로그는 굉장히 많은 용량을 필요로 하고 또한 시스템 부하율도 함께 고려하여 신중히 결정해야 합니다. 물론 로그를 남기는 것이 로그분석과 개별 사용자의 파일 업로드/다운로드 상황을 알 수 있는 방법이기는 하지만 시스템 상황을 고려해야 하는 의미입니다.

 

vsftpd_log_file=/var/log/vsftpd.log(기본값 = /var/log/vsftpd.log)

VsFTP의 기본 로그 파일을 지정합니다.

이 옵션은 xferlog_enable 옵션과 xferlog_std_format 옵션이 비활성화일 때 작동하며, dual_log_enable 옵션이나 syslog_enable 옵션이 활성화될때 사용됩니다.

 

dual_log_enable=NO (기본값 = NO)

2중 로그를 기록할 것인지에 대해 설정합니다.

만약 이 옵션을 활성화하면, /var/log/xferlog와 /var/log/vsftpd.log에 로그가 기록됩니다.

 

syslog_enable=NO (기본값 = NO)

syslogd 데몬을 이용해서 로그를 기록할 것인지 설정합니다.

 

xferlog_file=/var/log/vsftpd.log

ftp 로그파일의 위치를 결정하는 지시자입니다.

Vsftp는 기본적으로 /var/log/vsftpd.log 파일을 기본 로그파일로 사용합니다. 만약 로그파일 위치나 파일명을 변경하시려면 이 지시자에서 설정 변경하시면 됩니다.

 

xferlog_std_format=YES

로그파일에 남길 로그파일의 포맷을 기본포맷으로 남길 것인가(YES) 아닌가(NO)를 설정하는 지시자 입니다. 리눅스에서 ftp 기본 로그파일을 /var/log/xferlog을 사용합니다. 이 지시자는 이 파일의 표준포맷으로 로그를 남기도록 하는 설정입니다. 이 파일의 포맷보다는 vsftpd 로그포맷을 사용하시는 것이 보다 자세한 로그를 남길 수 있습니다. 즉, 디렉토리생성로그나 또는 로그인 로그 같은 상세로그까지 기록해 줍니다.

 

 

log_ftp_protocol=YES (기본값 = NO)

FTP Protocol의 모든 내용을 기록할지 설정합니다.

이 옵션을 활성화하면 FTP 명령어와 반응이 모두 로깅되므로 디버그에 유용하게 쓰입니다.

 

no_log_lock=NO (기본값 = NO)

로그 파일을 잠글것인지에 대해서 설정합니다.

이 옵션은 vsftpd가 로그 파일을 기록할 때, 파일을 잠그는 것을 막는 옵션 입니다.

보통은 활성화 하지 않아도 되며, 솔라리스/베리타스 파일 시스템 조합에서 때때로

로그파일을 잠그려는 시도를 하는 운영체제 시스템 버그를 피하기 위해 존재 합니다.

 

session_support=YES

이 설정은 YES로 설정되어 유효하게 되었을 때에는 바이너리파일인 wtmp에 ftp 접속관련 기록을 남기게 됩니다.

Last 라는 명령어는 각 사용자들의 접속기록을 wtmp 파일에서 가져와 확인하는 명령어이므로 이 설정이 적용되면 last 명령어로 ftp 접속기록을 확인 할 수 있게 됩니다.

 

⑨ 가상 사용자 설정

guest_enable=NO

가상유저 모드로 운영할 것인지에 대해 설정합니다. (기본값 = NO)

이 옵션을 활성화하면 모든 비익명 사용자는 가상 사용자로 접속이 됩니다.

 

guest_username=ftp

가상유저들의 실제 계정을 지정합니다. (기본값 = ftp)

 

virtual_use_local_privs=NO (기본값 = NO)

가상유저들의 권한을 실제 계정의 권한처럼 허용할 것인지를 설정합니다.

이 옵션이 활성화되어있지 않으면 가상유저는 FTP에 접속해서 파일을 생성하지 못합니다. 또한 가상유저는 기본적으로 anonymous의 권한을 갖고 있습니다.

 

user_sub_token=$USER (기본값 = none)

가상유저들을 지칭할 가상의 변수를 지정합니다.

 

local_root=/home/virtual/$USER (기본값 = none)

가상유저들이 로그인 후 이동될 디렉토리를 지정합니다.

 

⑩ 익명사용자 기본 설정

anonymous_enable=NO

익명(anonymous) 접속을 허용할 것인가(YES) 허용하지 않을 것인가(NO)를 결정하는 지시자입니다. 기본값은 YES로 되어있으며 익명계정 접속을 허용하지 않으려면 NO 로 설정하시기 바랍니다.

 

anon_max_rate=0 (기본값 = 0)

익명 사용자의 다운로드 최대전송률을 지정합니다. 다운로드 속도를 제한할때 사용하며, 단위는 bps 입니다.

 

allow_anon_ssl=NO (기본값 = NO)

익명사용자의 SSL을 통한 보안접속을 지원할 것인지에 대해 설정합니다.

이 옵션은 ssl_enable이 활성화 되었을 때만 적용됩니다.

 

deny_email_enable=YES (기본값 = NO)

로그인 거부 리스트 사용에 대한 설정을 합니다.

/etc/vsftpd.banned_emails 에 설정된 주소로 로그인을 거부할 수 있습니다.

만약 anonymous@ 라고 설정해두면, anonymous@를 사용하는 사용자는 접속할 수 없게됩니다.

 

banned_email_file=/etc/vsftpd.banned_emails (기본값 = /etc/vsftpd.banned_emails)

로그인 거부 파일을 지정합니다.

deny_email_enable 옵션을 활성화했을 경우에 리스트를 읽어올 파일을 지정합니다.

 

secure_email_list_enable=NO (기본값 = NO)

명시된 이메일 주소로만 접속을 허용할 지 설정합니다.

 

email_password_file=/etc/vsftpd.email_passwords (기본값 = /etc/vsftpd.email_passwords)

접속을 허용할 이메일 주소 파일을 지정합니다.

secure_email_list_enable 옵션을 활성화했을 경우에 리스트를 읽어올 파일을 지정합니다.

 

ftp_username=ftp (기본값 = ftp)

익명 사용자의 접속에 사용될 계정명을 지정합니다.

 

no_anon_password=NO (기본값 = NO)

익명 사용자가 접속할 때 패스워드를 묻지않고 접속시킬 것인지 설정합니다.

이 옵션을 활성화하면 접속시 패스워드를 묻지 않습니다.

 

one_process_model=NO (기본값 = NO)

클라이언트 접속마다 하나의 프로세스가 작동되도록 할 것인지 설정합니다.

이 옵션을 활성화하면 접속하는 수만큼 프로세스가 작동되므로 효율이 좋습니다.

 

anon_root=/var/ftp/pub (기본값 = none)

익명 사용자의 기본 디렉토리를 지정합니다.

일반적으로 익명 사용자의 접근을 허용하면 ftp_username에 지정된 사용자의 홈 디렉토리가 기본적으로 설정됩니다. 그렇지만 만약 변경할 필요가 있을 경우에 이 옵션을 사용하면 됩니다.

 

⑪ 익명사용자 권한 설정

anon_upload_enable=YES

익명(anonymous) 계정 사용자에게 파일 업로드를 허용할 것인가(YES) 허용하지 않을 것인가(NO) 의 여부를 설정하는 지시자입니다. 기본값은 허용하지 않는 NO 입니다. 가능한 익명 계정으로 접속한 사용자에게는 업로드 권한을 허용하지 않는 것이 보안에 훨씬 좋습니다. 따라서 가능한 NO로 설정하시기 바랍니다.

 

anon_mkdir_write_enable=YES

익명(anonymous) 계정 사용자에게 디렉토리 생성권한을 허용할 것인가(YES) 허용하지 않을 것인가(NO)의 여부를 설정하는 지시자 입니다. 기본값은 허용하지 않는 NO 입니다. 가능한 익명계정으로 접속한 사용자에게는 디렉토리 생성권한을 허용하지 않는 것이 보안에 훨씬 좋습니다. 따라서 가능한 NO로 설정하시기 바랍니다.

 

anon_world_readable_only=YES (기본값 = YES)

익명 사용자들의 다운로드에 대한 설정을 합니다.

익명 사용자들이 읽기 가능한 파일을 다운로드 할 수 있게 설정합니다.

 

anon_other_write_enable=NO (기본값 = NO)

익명 사용자의 파일 삭제,변경에 대한 설정을 합니다.

파일 삭제 및 파일명 변경등과 같은 기능을 사용할 수 있게 합니다.

 

chown_uploads=YES (기본값 = NO)

익명 사용자의 소유권 변경에 대한 설정을 합니다.

익명으로 업로드된 파일을 chown_username 옵션으로 명시된 사용자의 소유권으로 변경되도록 할 수 있습니다.

 

anon_umask=022 (기본값 = 077)

익명 사용자의 파일생성 umask 값을 지정 합니다.

umask에 대한 설명은 local_mask의 설명을 참조하시기 바랍니다.

 

chown_username=whoever (기본값 = root)

익명 사용자의 소유권 변경이 가능한 계정명을 설정합니다. 

2009. 3. 27. 17:50

리눅스 터미널에서 한글 깨질때 해결 방법

리눅스를 설치하게 되면 기본적으로 UTF8로 설치를 하게됩니다. 이 경우 ssh 의 접속 설정을 UTF8로 하더라도 한글이 깨지는 현상이 발생하게 되는데 아래와 같은 방법으로 변경하면 한글이 정상적으로 표시됩니다.

기본적으로 /etc/sysconfig/i18n 파일의 내용은 아래와 같습니다.
LANG="ko_KR.UTF-8"
SUPPORTED="ko_KR.UTF-8:ko_KR:ko"
SYSFONT="latarcyrheb-sun16"


이 내용을 아래와 같이 변경해줍니다.

LANG="ko_KR.eucKR"
SUPPORTED="en_US.UTF-8:en_US:en:ko_KR.eucKR:ko_KR:ko"
SYSFONT="lat0-sun16"
SYSFONTACM="8859-15"


그후에 source /etc/sysconfig/i18n 명령을 실행하시면 됩니다.