Home Database Mysql Tutorial vsftpd+MySQL创建虚拟用户在Debian Linux之下

vsftpd+MySQL创建虚拟用户在Debian Linux之下

Jun 07, 2016 pm 04:13 PM
debian l create user virtual

以下的文章主要讲述的是Debian Linux下对vsftpd+MySQL虚拟用户的具体作法,我前两天在相关网站看见Debian Linux下对vsftpd+MySQL虚拟用户的资料,觉得挺好,就拿出来供大家分享。 今天闲来无事做了个ftp,原因很简单就是为了能在别处看到的好东西直接放到我

以下的文章主要讲述的是Debian Linux下对vsftpd+MySQL虚拟用户的具体作法,我前两天在相关网站看见Debian Linux下对vsftpd+MySQL虚拟用户的资料,觉得挺好,就拿出来供大家分享。

今天闲来无事做了个ftp,原因很简单就是为了能在别处看到的好东西直接放到我的机器上,嘿嘿!linux下选择ftp服务器还真是不容易,经过一阵思索后就选择了vsftpd,理由就是它号称是linux下最安全的ftp服务器还有还有好多的大型站点都用它来做服务器(这样用起来也比较有面子 :) )。

为了怕在我输入密码时被别人偷看到然后登入我机器乱搞,在加上我本来就讨厌系统有那么多的用户(其实也是像显示自己的手平),所以我决定采用虚拟用户,因为机器中装有MySQL(和PHP搭配之最佳组合),于是我就想将vsftpd+MySQL虚拟用户数据放在MySQL(和PHP搭配之最佳组合)中,好了,就侃到这里,下面进入正题!

第一步:

安装vsftpd

apt-get install vsftpd (Debian就是爽啊!)

系统会自动生成一个配置文件和一个ftp用户供匿名用户使用,vsftpd使用pam方式来验证虚拟用户,因为vsftpd+MySQL虚拟用户的信息保存在数据库中,所以我们还需要一个能够读取数据库内容的本地用户,而且还需要设置它的本地目录:

<ol class="dp-xml">
<li class="alt"><span><span>#mkdir /var/ftp  </span></span></li>
<li><span>#useradd -d ftpguest /var/ftp  </span></li>
<li class="alt"><span>#chown ftpguest.nogroup /var/ftp  </span></li>
</ol>
Copy after login

第二步:安装MySQL(和PHP搭配之最佳组合)

apt-get install MySQL(和PHP搭配之最佳组合)-server MySQL(和PHP搭配之最佳组合)-clent

建立数据库,并添加用户

<ol class="dp-xml">
<li class="alt">#MySQL<span>(和PHP搭配之最佳组合) -p </span>MySQL<span>(和PHP搭配之最佳组合)</span><span>>create ftpu;   </span>
</li>
<li>MySQL<span>(和PHP搭配之最佳组合)</span><span class="tag">></span><span>use ftpu;   </span>
</li>
<li class="alt">MySQL<span>(和PHP搭配之最佳组合)</span><span class="tag">></span><span>create table user(name char(20) binary,passwd char(20) binary);   </span>
</li>
<li>MySQL<span>(和PHP搭配之最佳组合)</span><span class="tag">></span><span>insert into user (name,passwd) values ('test1',password('1234567'));   </span>
</li>
<li class="alt">MySQL<span>(和PHP搭配之最佳组合)</span><span class="tag">></span><span>insert into user (name,passwd) values ('test2',password('7654321'));   </span>
</li>
<li>MySQL<span>(和PHP搭配之最佳组合)</span><span class="tag">></span><span>quit   </span>
</li>
<li class="alt"><span>让ftpguest能访问ftpu和表user:   </span></li>
<li>
<span>#</span>MySQL<span>(和PHP搭配之最佳组合) -u root </span>MySQL<span>(和PHP搭配之最佳组合) <br>-p </span>MySQL<span>(和PHP搭配之最佳组合)</span><span class="tag">></span><span>grant select on ftpu.user to ftpguest@localhost identified by '123456';   </span>
</li>
</ol>
Copy after login

MySQL(和PHP搭配之最佳组合)>quit

第三步:因为vsftpd是通过PAM验证

所以我们还需要一个MySQL(和PHP搭配之最佳组合)通过PAM验证的包,在Debian下它叫做libpam-MySQL(和PHP搭配之最佳组合)

apt-get install libpam-MySQL(和PHP搭配之最佳组合)

然后打开vsftpd的pam验证:

<ol class="dp-xml"><li class="alt"><span><span>#vi /etc/pam.d/vsftpd  </span></span></li></ol>
Copy after login

将以前的内容注释掉,然后加入以下内容:

auth required pam_MySQL(和PHP搭配之最佳组合).so user=ftpguest passwd=123456 host=localhost db=ftpu table=user usercolumn=name passwdcolumn=passwd crypt=2

account required pam_MySQL(和PHP搭配之最佳组合).so user=ftpguest passwd=123456 host=localhost db=ftpu table=user usercolumn=name passwdcolumn=passwd crypt=2

上面的内容应该能看明白吧,那个crypt=2表示经过MySQL(和PHP搭配之最佳组合)的password()机密后的东西!

第四步:修改vsftpd.conf文件

<ol class="dp-xml"><li class="alt"><span><span>#vi /etc/vsftpd.conf  </span></span></li></ol>
Copy after login

加入:

<ol class="dp-xml">
<li class="alt"><span><span class="attribute">uest_enable</span><span>=</span><span class="attribute-value">yes</span><span>   </span></span></li>
<li>
<span class="attribute">guest_username</span><span>=</span><span class="attribute-value">ftpguest</span><span>   </span>
</li>
<li class="alt"><span>#表示ftpguest为vsftp的虚拟用户   </span></li>
<li>
<span class="attribute">virtual_use_local_privs</span><span>=</span><span class="attribute-value">yes</span><span>   </span>
</li>
<li class="alt"><span> </span></li>
</ol>
Copy after login

vsftpd+MySQL虚拟用户与本地用户有相同的权限

<ol class="dp-xml">
<li class="alt"><span><span class="attribute">write_enable</span><span>=</span><span class="attribute-value">yes</span><span>   </span></span></li>
<li>
<span class="attribute">anon_upload_enable</span><span>=</span><span class="attribute-value">yes</span><span>   </span>
</li>
<li class="alt">
<span class="attribute">anon_other_write_enable</span><span>=</span><span class="attribute-value">yes</span><span>   </span>
</li>
</ol>
Copy after login

允许虚拟用户上传,修改和删除文件

<ol class="dp-xml"><li class="alt"><span><span class="attribute">chroot_local_user</span><span>=</span><span class="attribute-value">yes</span><span>  </span></span></li></ol>
Copy after login

虚拟用户只能访问自己的目录

<ol class="dp-xml">
<li class="alt"><span><span class="attribute">anonymous_enable</span><span>=no   </span></span></li>
<li>
<span class="attribute">local_enable</span><span>=</span><span class="attribute-value">yes</span><span>   </span>
</li>
</ol>
Copy after login

关闭匿名用户访问,开启本地用户访问

第五步:

本来来到第四步已经完成了,可是后来一想,不对,那要是每次上传的东西都不同,到时把那个目录弄得乱七八糟的怎么管理啊,能不能为每个vsftpd+MySQL虚拟用户创建一个目录呢,比如说将music用户上传的文件放在放在~/music下,将doc用户上传的文件放在~/doc下呢?

能!当然能了,看看我怎么做?

首先在数据库中添加music和doc两个vsftpd+MySQL虚拟用户接下来:

<ol class="dp-xml">
<li class="alt"><span><span>#mkdir /etc/vsftpd_user_conf   </span></span></li>
<li><span>#cd /etc/vsftpd_user_conf   </span></li>
<li class="alt"><span>#touch music   </span></li>
<li>
<span>#echo "</span><span class="attribute">local_root</span><span>=/home/username/music" </span><span class="tag">></span><span> music   </span>
</li>
<li class="alt"><span>#touch doc   </span></li>
<li>
<span>#echo "</span><span class="attribute">local_root</span><span>=/home/username/doc" </span><span class="tag">></span><span> doc   </span>
</li>
<li class="alt"><span>#mkdir /home/username/music   </span></li>
<li><span>#chown ftpguest.nogroup /home/username/music   </span></li>
<li class="alt"><span>#chmod 600 /home/username/music   </span></li>
<li><span>#chown ftpguest.nogroup /home/username/doc   </span></li>
<li class="alt"><span>#chmod 600 /home/username/doc   </span></li>
</ol>
Copy after login

然后在vsftpd.conf中加入: user_config_dir=/etc/vsftpd_user_conf,大功告成,你明白了吗?


Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to use Xiaohongshu account to find users? Can I find my mobile phone number? How to use Xiaohongshu account to find users? Can I find my mobile phone number? Mar 22, 2024 am 08:40 AM

With the rapid development of social media, Xiaohongshu has become one of the most popular social platforms. Users can create a Xiaohongshu account to show their personal identity and communicate and interact with other users. If you need to find a user’s Xiaohongshu number, you can follow these simple steps. 1. How to use Xiaohongshu account to find users? 1. Open the Xiaohongshu APP, click the &quot;Discover&quot; button in the lower right corner, and then select the &quot;Notes&quot; option. 2. In the note list, find the note posted by the user you want to find. Click to enter the note details page. 3. On the note details page, click the &quot;Follow&quot; button below the user's avatar to enter the user's personal homepage. 4. In the upper right corner of the user's personal homepage, click the three-dot button and select &quot;Personal Information&quot;

How to install Snap on Debian 12 How to install Snap on Debian 12 Mar 20, 2024 pm 08:51 PM

Snap is an external package manager designed for Linux systems that provides you with a convenient way to install containerized applications. Snap allows you to easily download and install packages without worrying about installing additional dependencies. The manager automatically resolves the dependencies required by the package, ensuring that the package runs smoothly on your system. Snap complements the native apt package manager, giving you another option for installing and running applications on your system. In this guide, you will find a complete guide on how to install Snap on Debian12. Outline: How to install Snap on Debian12 How to find package availability on Snap How to find information about packages on Snap

Log in to Ubuntu as superuser Log in to Ubuntu as superuser Mar 20, 2024 am 10:55 AM

In Ubuntu systems, the root user is usually disabled. To activate the root user, you can use the passwd command to set a password and then use the su- command to log in as root. The root user is a user with unrestricted system administrative rights. He has permissions to access and modify files, user management, software installation and removal, and system configuration changes. There are obvious differences between the root user and ordinary users. The root user has the highest authority and broader control rights in the system. The root user can execute important system commands and edit system files, which ordinary users cannot do. In this guide, I'll explore the Ubuntu root user, how to log in as root, and how it differs from a normal user. Notice

How to install Steam on Debian 12 How to install Steam on Debian 12 Mar 21, 2024 pm 10:10 PM

STEAM is a popular gaming platform developed by Valve Corporation that allows you to buy, download, install and play games. It provides features such as automatic updates, matchmaking, and a community forum to resolve software-related issues. In addition to this, you can also use Steam to interact with other players and developers as it has extensive community support. In this guide you will learn: How to install Steam on Debian12 How to run Steam on Debian12 How to remove Steam from Debian12 Conclusion How to install Steam on Debian12 You can install Steam on Debian12: Debian Official Repository deb packages

What is sudo and why is it important? What is sudo and why is it important? Feb 21, 2024 pm 07:01 PM

sudo (superuser execution) is a key command in Linux and Unix systems that allows ordinary users to run specific commands with root privileges. The function of sudo is mainly reflected in the following aspects: Providing permission control: sudo achieves strict control over system resources and sensitive operations by authorizing users to temporarily obtain superuser permissions. Ordinary users can only obtain temporary privileges through sudo when needed, and do not need to log in as superuser all the time. Improved security: By using sudo, you can avoid using the root account during routine operations. Using the root account for all operations may lead to unexpected system damage, as any mistaken or careless operation will have full permissions. and

How to install Zig programming language 12 on Debian How to install Zig programming language 12 on Debian Feb 19, 2024 pm 08:39 PM

Zig is an emerging programming language that focuses on security, performance and maintainability. Its easy-to-learn syntax, powerful standard library, and advanced compile-time features give it great potential in systems programming. Installing Zig Programming Language 12Bookworm on Debian Keeping your system up to date is a crucial best practice in system administration. Before installing new software, run the command to make sure your Debian system is up to date. sudoaptupdatesudoaptupgrade This command will update the package list for upgrades and new package installations. Step 2. Install Zig Programming Language on Debian 12. There are two main ways to install Zig on Debian 12: One is through AP

How to create a family with Gree+ How to create a family with Gree+ Mar 01, 2024 pm 12:40 PM

Many friends expressed that they want to know how to create a family in Gree+ software. Here is the operation method for you. Friends who want to know more, come and take a look with me. First, open the Gree+ software on your mobile phone and log in. Then, in the options bar at the bottom of the page, click the "My" option on the far right to enter the personal account page. 2. After coming to my page, there is a "Create Family" option under "Family". After finding it, click on it to enter. 3. Next jump to the page to create a family, enter the family name to be set in the input box according to the prompts, and click the "Save" button in the upper right corner after entering it. 4. Finally, a "save successfully" prompt will pop up at the bottom of the page, indicating that the family has been successfully created.

Analysis of user password storage mechanism in Linux system Analysis of user password storage mechanism in Linux system Mar 20, 2024 pm 04:27 PM

Analysis of user password storage mechanism in Linux system In Linux system, the storage of user password is one of the very important security mechanisms. This article will analyze the storage mechanism of user passwords in Linux systems, including the encrypted storage of passwords, the password verification process, and how to securely manage user passwords. At the same time, specific code examples will be used to demonstrate the actual operation process of password storage. 1. Encrypted storage of passwords In Linux systems, user passwords are not stored in the system in plain text, but are encrypted and stored. L

See all articles