Linux vsftp virtual user adding script

Source: Internet
Author: User

#! /Bin/bash

# This is a script for add ftpusers

While:; do

If [-z $ user]; then

Read-p "please enter your ftp username:" user

Else

While:; do

If [$ (echo $ pw | wc-c)-le 12]; then

Read-p "please enter your ftp password (please enter the password, any character above 12 characters):" pw

Else

Sed-I '$ a \' $ user' \ n' $ pw '/etc/vsftpd/vuser.txt

Db_load-T-t hash-f/etc/vsftpd/vuser.txt/etc/vsftpd/vuser. db

Touch/etc/vsftpd/user_dir/$ user

While:; do

If ["$ (echo $ local_root | cut-c 1-9 )"! = "/Data/www"]; then

Read-p "please enter ftp home directory (enter the full path, starting with/data/www):" local_root

Else

Echo "local_root = $ local_root">/etc/vsftpd/user_dir/$ user

While:; do

If ["$ permit "! = "Upload"-a "$ permit "! = "Ro"-a "$ permit "! = "Rw"]; then

Read-p "please enter ftp user permit (upload | ro | rw):" permit

Else

If [$ permit = "upload"]; then

Sed-I '$ a \ anon_upload_enable = YES \ nanon_mkdir_write_enable = YES'/etc/vsftpd/user_dir/$ user

Echo "the $ user permit is $ permit, thanks for use scripts"

Fi

If [$ permit = "ro"]; then

Echo "the $ user permit is $ permit, thanks for use scripts"

Fi

If [$ permit = "rw"]; then

Sed-I '$ a \ anon_upload_enable = YES \ nanon_mkdir_write_enable = YES \ nanon_other_write_enable = YES'/etc/vsftpd/user_dir/$ user

Echo "the $ user permit is $ permit, thanks for use scripts"

Fi

Exit

Fi

Done

Fi

Done

Fi

Done

Fi

Done


This article from "Step by Step crawling" blog, please be sure to keep this source http://linchqd.blog.51cto.com/7753012/1303786

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.