SoftGanz By Little Bear.

Web & Software Developer Gang.

Server

Setup FTP Server under Ubuntu/Debian

by Little Bear @December,22 2014 21.35 ( IP : 49...101 ) | Tags : Server , Ubuntu

เก็บไว้ก่อน เดี๋ยวค่อยมาแปลและเขียนใหม่นะครับ

This article contains a brief introduction to set up an FTP-Server under Debian Linux. Activation of an FTP server should be done similarly with other distributions of Linux. Debian 5.0 (x86) was used as the test system.

Contents

  1. Installation of the required proftpd Package
  2. Adjusting the Configuration
  3. Anonymous FTP
  4. Re-loading the Configuration and Re-starting the FTP Server
  5. Links

Installation of the required proftpd Package

ProFTPd FTP-Server was used for this introduction because of its simply installation and configuration.

apt-get install proftpd

If the package cannot be found, update the local list of packages using:

apt-get update

If the package still cannot be installed after that, check the /etc/apt/sources.list on the appropriate Debian mirror server. You will find more information about this in the article Debian Mirror.

Indicate in the subsequent inquiry whether the FTP server should act as a standalone server (standalone) or as a service of inetd. In this example, the standalone option has been selected. Adjusting the Configuration

Our configuration assumes that we will login using system users found in the ftpuser group.

In order to adjust the configuration to your needs, edit the /etc/proftpd/proftpd.conf file.

If you are not using IPv6, this feature should be deactivated first:

UseIPv6 off

After that, we will add the following instruction at the end of the file:

<Global>
&nbsp; &nbsp; RequireValidShell off
</Global>

DefaultRoot ~ ftpuser

<Limit LOGIN>
&nbsp; &nbsp; DenyGroup !ftpuser
</Limit>

What do the instructions mean?

As a first step, we told ProFTPd that users wanting to login do not need a shell. Afterwards, we instructed ProFTPd to lock users in their home directory using DefaultRoot. Finally, we specified that only those users who are members of the ftpuser group could login.

We will now restart our FTP server so that our configuration takes effect:

/etc/init.d/proftpd restart

Then, we will create the ftpuser group and a first user that will be able to login.

addgroup ftpuser

Now, we create the user:

adduser ftpbenutzer -shell /bin/false -home /var/www

Finally, we assign the user to the ftpuser group:

adduser ftpbenutzer ftpuser

That’s everything. You should now be able to login with the user via FTP.

You have to run sudo deluser username groupname to delete a user from it's corresponding group. And run this sudo deluser --group groupname command to delete a group.

Anonymous FTP

By adding the following section to the etc/proftpd/proftpd.conf file, you will also give anonymous users (read) access to the FTP area:

.
.
.
<Anonymous ~ftp>
&nbsp; User&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ftp
&nbsp; Group&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  nogroup
&nbsp; # We want clients to be able to login with "anonymous" as well as "ftp"
&nbsp; UserAlias&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  anonymous ftp
&nbsp; # Cosmetic changes, all files belong to ftp user
&nbsp; DirFakeUser&nbsp;  on ftp
&nbsp; DirFakeGroup on ftp

&nbsp; RequireValidShell&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  off

&nbsp; # Limit the maximum number of anonymous logins
&nbsp; MaxClients&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 10

&nbsp; # We want 'welcome.msg' displayed at login, and '.message' displayed
&nbsp; # in each newly chdired directory.
&nbsp; DisplayLogin&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; welcome.msg
&nbsp; DisplayFirstChdir&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  .message

&nbsp; # Limit WRITE everywhere in the anonymous chroot
&nbsp; <Directory *>
&nbsp; &nbsp; <Limit WRITE>
&nbsp; &nbsp; &nbsp; DenyAll
&nbsp; &nbsp; </Limit>
&nbsp; </Directory>

#&nbsp;  # Uncomment this if you're brave.
#&nbsp;  # <Directory incoming>
#&nbsp;  #&nbsp;  # Umask 022 is a good standard umask to prevent new files and dirs
#&nbsp;  #&nbsp;  # (second parm) from being group and world writable.
#&nbsp;  #&nbsp;  Umask&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  022&nbsp; 022
#&nbsp;  #&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Limit READ WRITE>
#&nbsp;  #&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; DenyAll
#&nbsp;  #&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </Limit>
#&nbsp;  #&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <Limit STOR>
#&nbsp;  #&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; AllowAll
#&nbsp;  #&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </Limit>
#&nbsp;  # </Directory>

</Anonymous>
.
.
.

To make sure, that user "ftp" is able to login anonymously to ftp-space, you have to add the user to the group "ftpuser":

adduser ftp ftpuser

Re-loading the Configuration and Re-starting the FTP Server

The configuration will have to be re-loaded after the adjustments to the /etc/proftpd/proftpd.conf file:

/etc/init.d/proftpd reload

Because the FTP server will be stopped when re-loading the configuration, it will also have to be re-started afterwards:

/etc/init.d/proftpd start


Links



ลิงก์ผู้สนับสนุน

Relate topics

แสดงความคิดเห็น

« 5913
หากท่านไม่ได้เป็นสมาชิก ท่านจำเป็นต้องป้อนตัวอักษรของ Anti-spam word ในช่องข้างบนให้ถูกต้อง
The content of this field is kept private and will not be shown publicly. This mail use for contact via email when someone want to contact you.
Bold Italic Underline Left Center Right Ordered List Bulleted List Horizontal Rule Page break Hyperlink Text Color :) Quote
คำแนะนำ เว็บไซท์นี้สามารถเขียนข้อความในรูปแบบ มาร์คดาวน์ - Markdown Syntax:
  • วิธีการขึ้นบรรทัดใหม่โดยไม่เว้นช่องว่างระหว่างบรรทัด ให้เคาะเว้นวรรค (Space bar) ที่ท้ายบรรทัดจำนวนหนึ่งครั้ง
  • วิธีการขึ้นย่อหน้าใหม่ซึ่งจะมีการเว้นช่องว่างห่างจากบรรทัดด้านบนเล็กน้อย ให้เคาะ Enter จำนวน 2 ครั้ง