Strona 2 z 2

: 04 grudnia 2014, 18:05
autor: kodama
Ja ci mogę pokazać jak ja to mam zorganizowane - to się chyba nazywa "virtual users" :] Zaleta? Jak dla mnie jest taka, że nie trzeba dodawać użytkownika do systemu. Ale do rzeczy:
proftpd.conf (zwróć uwagę na pogrubione linijki)

Kod: Zaznacz cały

#/etc/profptd/proftpd.conf

#######################################################################
# Server Config                                                       #
#######################################################################

Include            /etc/proftpd/modules.conf
Include         /etc/proftpd/tls.conf

ServerName        "kodamowy FTP server"
ServerType        standalone
ServerAdmin        kodamus@o2.pl
DefaultServer        on
AccessGrantMsg        "Użytkownik %u zalogowany."

# keep the required auth module only
AuthOrder        mod_auth_file.c

UseReverseDNS        off
RequireValidShell       off

# we want the main server instance to listen on a specific IP
DefaultAddress          192.168.0.31
Port            21
PassivePorts            60001 61000

# never ever run as root
User            proftpd
Group            nogroup

# pid file
ScoreboardFile        /var/run/proftpd.score

# for DOS prevention, only works in standalone mode
MaxInstances        20

# for passive FTP mode
 MasqueradeAddress    XXX.XXX.XXX.XXX

MultilineRFC2228    on
ShowSymlinks        off
UseIPv6            off
DefaultTransferMode    binary

WtmpLog                 off
TransferLog        /var/log/proftpd/xferlog
SystemLog        /var/log/proftpd/proftpd.log

#######################################################################
# Global Config                                                       #
#######################################################################

<Global>
 RootLogin        off
 [B]AuthUserFile           /etc/proftpd/ftp.users[/B]

 # jailing
 [B]DefaultRoot /home/ftp/[/B]
 #DefaultChdir        /ftp/shared

 # give out minimal information
 ServerIdent        on "Private FTP Server"
 IdentLookups        off

 # no welcome message until user has authenticated
 DeferWelcome           off
 DisplayLogin        /etc/proftpd/welcome.msg
 DisplayConnect         /etc/issue.net

 TimeoutLogin        120
 TimeoutNoTransfer    300
 TimeoutStalled        3600
 TimeoutIdle        600

 MaxClients         5 "Sorry, ftp server has reached its maximum user limit (%m)"
 MaxClientsPerUser     5 "Sorry, no more than %m connections per user."

 # restrict sandy's uploads to 1 gigabyte per file
 # MaxStoreFileSize 1 Gb user sandy 

 # allow unlimited upload and download size for everyone else
 # MaxStoreFileSize *
 # MaxRetrieveFileSize *

 MaxLoginAttempts    3
 DenyFilter        \*.*/

 Umask            022 
 AllowOverwrite        on
 AllowOverride        off

 # allow to resume not only the downloads, but the uploads too
 AllowRetrieveRestart    on
 AllowStoreRestart    on

 RequireValidShell    off
</Global>

<IfModule mod_delay.c>
 DelayEngine on
</IfModule>
<Limit SITE_CHMOD>
 DenyAll
</Limit>
#######################################################################
# VirtualHosts #
#######################################################################

# for future usage
# Include /etc/proftpd/virtuals.conf

<Directory /home/ftp>
Umask 022 022
AllowOverwrite off
    <Limit MKD STOR DELE XMKD RNRF RNTO RMD XRMD>
    DenyAll
    </Limit>
</Directory>

<Directory /home/ftp/down/*>
Umask 022 022
AllowOverwrite off
    <Limit MKD STOR DELE XMKD RNEF RNTO RMD XRMD>
    DenyAll
    </Limit>
</Directory>

<Directory /home/ftp/up/*>
Umask 022 022
AllowOverwrite on
    <Limit READ RMD DELE>
          DenyAll
        </Limit>

        <Limit STOR CWD MKD>
          AllowAll
        </Limit>
</Directory>

#~~~~Prywatny katalog na FTP, nikt nie widzi zawartości tylko kodama

<Directory /home/ftp/priv/*>
Umask 022 022
AllowOverwrite on
    <Limit ALL>
    AllowUser kodama
        DenyAll
        </Limit>

</Directory>



  <IfModule mod_memcache.c>
    # Enable mod_memcache
    MemcacheEngine on

    # Tell mod_memcache where to log its messages
    MemcacheLog /path/to/proftpd/memcache.log

    # Tell mod_memcache where to find the memcached servers
#    MemcacheServers 192.168.0.10:11211 192.168.0.11:11211
  </IfModule>
ftp.users ma postać:

Kod: Zaznacz cały

kodama:$1$la8ZDRY7$sIeTWmbt..08FeYfJcpGD1:1010:1010:kodama:/home/ftp:/bin/false
robert:$1$GOPesKKT$x0TKEhapeNn3RF0kCnDoM/:1011:1011:robert:/home/ftp:/bin/false
adam:$1$LzM7rs32$anWjqX7YxQLb6uIDOtrL/.:1012:1012:adam:/home/ftp:/bin/false
czyli w postaci
nazwa_uzytkownika : md5(hasło)* : uid : gid : nazwa_uzytkownika : katalog_ftp : shell**
* - hasło generuję tak:

Kod: Zaznacz cały

mkpasswd --hash=md5
 
uid i gid sobie nadaję jakiś tam kolejny z brzegu
** - /bin/false mam dodane na końcu /etc/shells

Ogólnie mam napisany skrypt (no, zalążek ;) ), który mi to robi z automatu wszystko.
I taka konfiguracja śmiga. Użytkownik nie wyjdzie poza katalog /home/ftp, a dodatkowo nikt (oprócz mnie) nie zajrzy do katalogu priv. Do całości mam jeszcze dodane SSL. Bardziej w kwestii nauki to sobie zrobiłem niż w jakimś konkretnym celu. No ale mam i działa.