We have already shown you How to Setup VSFTPD Server on CentOS 6.5/6.4 in our previous article. In that method, the users created in the server itself were logged-in to FTP server (i.e. local users). But what if the users who don’t have a local account in FTP server?

Well, in this article we let us setup vsftpd server with virtual users. ie. the users who don’t have local account in the FTP server itself can login to FTP server.

I assume that you already have installed and configured FTP server. If didn’t, visit to the above mentioned link to setup FTP server.

Install Berkeley Database(db4)

In this method, we use Berkeley database(db4(version4) to store virtual user names with their passwords. First install db4-utils package if it not installed:

# yum install db4-utils db4 -y

Create database file for virtual users

First create a plain text file and enter the virtual user names and their passwords one by one. Then create the db file from the plain text file.

For instance, i create a plain text file called virtual_users.txt in /home directory with username senthil and password centos:

# vi /home/virtual_users.txt

Add username and password one by one.

senthil
centos

Save and exit the file. Run the following command to create database file:

# db_load -T -t hash -f /home/virtual_users.txt /etc/vsftpd/virtual_users.db

Here virtual.db is the actual database file for virtual users.

Create a PAM file

Now create a PAM file to use the database virtual_users.db which we created from the plain text file. Create a file/etc/pam.d/vsftpd_virtual,

# vi /etc/pam.d/vsftpd_virtual

Add the following lines:

#%PAM-1.0
auth    required        pam_userdb.so   db=/etc/vsftpd/virtual_users
account required        pam_userdb.so   db=/etc/vsftpd/virtual_users
session required        pam_loginuid.so

Save and exit the file.

vsftpd configuration

Edit file /etc/vsftpd/vsftpd.conf,

# vi /etc/vsftpd/vsftpd.conf

Make sure that you have added or edited the following lines as shown below:

# Allow anonymous FTP? (Beware - allowed by default if you comment this out).
anonymous_enable=NO # Uncomment this to allow local users to log in.
local_enable=YES ## Enable virtual users
guest_enable=YES ## Virtual users will use the same permissions as anonymous
virtual_use_local_privs=YES #
# Uncomment this to enable any form of FTP write command.
write_enable=YES ## PAM file name
pam_service_name=vsftpd_virtual ## Home Directory for virtual users
user_sub_token=$USER
local_root=/ftp/virtual/$USER # You may specify an explicit list of local users to chroot() to their home
# directory. If chroot_local_user is YES, then this list becomes a list of
# users to NOT chroot().
chroot_local_user=YES ## Hide ids from user
hide_ids=YES

Save and exit the file.

Now create home directories for virtual users:

# mkdir -p /ftp/virtual/senthil
# chown -R ftp:ftp /ftp/virtual/senthil/

Start or restart vsftpd service:

# service vsftpd restart

Now try to login to FTP server using virtual user senthil with password centos:

# ftp 192.168.1.101
Connected to 192.168.1.101 (192.168.1.101).
220 Welcome to UNIXMEN FTP service.
Name (192.168.1.101:root): senthil
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp>

Now you will able to login to FTP server with user senthil since i didn’t create any user called senthil.

Verify the log files using the following command:

# tail -f /var/log/secure

Sample output:

Dec 24 18:32:04 server vsftpd[3557]: pam_userdb(vsftpd_virtual:auth): user 'senthil' granted access

Login via your browser

Setup VSFTPD Server with Virtual Users On CentOS, RHEL, Scientific Linux 6.5/6.4/6.3的更多相关文章

  1. Install LAMP Server (Apache, MariaDB, PHP) On CentOS/RHEL/Scientific Linux 7

    Install LAMP Server (Apache, MariaDB, PHP) On CentOS/RHEL/Scientific Linux 7 By SK  - August 12, 201 ...

  2. 在CentOS/RHEL/Scientific Linux 6下安装 LAMP

    LAMP 是服务器系统中开源软件的一个完美组合.它是 Linux .Apache HTTP 服务器.MySQL 数据库.PHP(或者 Perl.Python)的第一个字母的缩写代码.对于很多系统管理员 ...

  3. Setup FTP Server On CentOS, RHEL, Scientific Linux 6.5/6.4/6.3

    setsebool allow_ftpd_full_access onsetsebool -P ftp_home_dir on vsftpd (Very Secure File Transport P ...

  4. linux之 CentOS/RHEL/Scientific Linux 6 & 7上安装Telnet

    声明: 在安装和使用Telnet之前,需要记住以下几点. 在公网(WAN)中使用Telnet是非常不好的想法.它会以明文的格式传输登入数据.每个人都可以看到明文.如果你还是需要Telnet,强烈建议你 ...

  5. setting up a IPSEC/L2TP vpn on CentOS 6 or Red Hat Enterprise Linux 6 or Scientific Linux

    This is a guide on setting up a IPSEC/L2TP vpn on CentOS 6 or Red Hat Enterprise Linux 6 or Scientif ...

  6. 【Linux】YUM Repositories for CentOS, RHEL & Fedora Systems

    这里是官方wiki:https://wiki.centos.org/AdditionalResources/Repositories 一.简介 YUM(Yellowdog Updater Modifi ...

  7. Setup and Configure the vsftpd server in CentOS 7 operation system

    ############################################################################## 1. close the firewall ...

  8. setup FTP server on CentOS 7

    Setup FTP Server on CentOS 7 Install vsftpd vsftpd (Very Secure File Transport Protocol Daemon) is a ...

  9. How to setup vsftpd FTP file Server on Redhat 7 Linux

    Forward from: https://linuxconfig.org/how-to-setup-vsftpd-ftp-file-server-on-redhat-7-linux How to s ...

随机推荐

  1. Android学习笔记1:Activity与View

    推荐一系列优秀的Android开发源码 Activity是Android应用中负责与用户交互的组件. View组件是所有UI控件.容器控件的基类,View组件就是Android应用中用户实实在在看到的 ...

  2. vimrc语法

    前言 工欲善其事,必先利其器.一个programmer必然要先有一个好的editor.vim就是一个十分强大的编辑器.它的强大之处,在于其个性化和可定制.学习vim,就像学习Linux,学习perl, ...

  3. 制作静态库文件(.a文件)

    制作静态库文件(.a文件) 1.创建静态库工程: 在Xcode中new一个新的project,选择IOS下面的Framework&Library,下面有一个Cocoa Touch Static ...

  4. 【转】[慢查优化]联表查询注意谁是驱动表 & 你搞不清楚谁join谁更好时请放手让mysql自行判定

    转自:http://zhengyun-ustc.iteye.com/blog/1942797 写在前面的话: 不要求每个人一定理解 联表查询(join/left join/inner join等)时的 ...

  5. nyoj 483 Nightmare【bfs+优先队列】

    Nightmare 时间限制:1000 ms  |  内存限制:65535 KB 难度:4   描述 Ignatius had a nightmare last night. He found him ...

  6. Nginx具体的压缩配置

    以下是自学it网--中级班上课笔记 网址:www.zixue.it 常用以下配置 gzip on|off gzip_buffers 4K|8K 缓冲(和硬盘块相当) gzip_comp_level [ ...

  7. oc学习之路----多级指针的使用和内存分析

    ---恢复内容开始--- 精髓:要熟悉指针的使用,首先要熟悉指针的各种状态存得是什么数据.(以一级指针 int *p1 二级指针:int **p2 三级指针:int ***p3为例) 一级指针:*p1 ...

  8. android设备连接不上电脑的解决方法

    先检查手机usb调试是否开启,已经开启还是连不上按照以下步骤操作: 1. 打开cmd,输入adb devices  查看设备是否连接 2.服务未启动,先杀掉服务:adb kill-server 3.启 ...

  9. LeetCode Search in Rotated Sorted Array 在旋转了的数组中查找

    Search in Rotated Sorted Array Suppose a sorted array is rotated at some pivot unknown to you before ...

  10. Qt4--加密日记本(子例化QMainWindow文本加密解密)

    近来刚学习Qt4编程,想找个实例练习练习,于是产生了一个想法,就是怎么样做一个文本加密,这样,自己保存的一些文档可以通过软件 生成加密文本,到时候要看的时候,通过自己的软件读取就可以.既然有想法了,那 ...