setup FTP server di UBUNTU 10.04
#1
Thumbs Up 
silahkan di edit sendiri ya ..

Code:
#!/bin/bash
# This script installs and setup vsftp with virtual users
# Note!: This script assumes that the following is install:
# libpam-mysql mysql-server mysql-client

# root password
P=PasswordForYourDBAdmin
D=vsftpd
# root
U=DBAdminUserName
# Name of the vsftp admin and also the folder where all the dirs will be created
S=vsftpdAdminName
# Chosen password for vsftpd admin
SP=vsftpdPassword

# Install vsftp
apt-get install vsftpd

# Create a backupcopy of the conf, so you can mess around
cp /etc/vsftpd.conf /etc/vsftpd.conf.bak

# Create the MySQL database for vsftpd
# Grant access rights for vsftpd admin user
# Create the table to hold user accounts/dirs

echo "create database '$D';" | mysql -u$U --password=$P

echo "GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP ON vsftpd.* TO '$S'@'localhost' IDENTIFIED BY '$SP';" | mysql -u$U --password=$P

echo "GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP ON vsftpd.* TO '$S'@'localhost.localdomain' IDENTIFIED BY '$SP';" | mysql -u$U --password=$P

echo "FLUSH PRIVILEGES;" | mysql -u$U --password=$P

echo "CREATE TABLE  `vsftpd`.`accounts` (
`id` INT NOT NULL AUTO_INCREMENT ,
`username` VARCHAR( 30 ) NOT NULL ,
`pass` VARCHAR( 50 ) NOT NULL ,
PRIMARY KEY (  `id` )
) ENGINE = MYISAM ;" | mysql -u$U --password=$P $D

# Create the global ftp user and the directory for all ftp directories
useradd -d /home/sites -g nogroup -m -s /bin/false sites

# Erase the contents of the vsftp.conf
cat /dev/null > /etc/vsftp.conf

# Add the settings for using virtual host to the conf file
echo "listen=YES
anonymous_enable=NO
local_enable=YES
write_enable=YES
local_umask=022
dirmessage_enable=YES
xferlog_enable=YES
connect_from_port_20=YES
nopriv_user=sites
chroot_local_user=YES
secure_chroot_dir=/var/run/vsftpd
pam_service_name=vsftpd
rsa_cert_file=/etc/ssl/certs/vsftpd.pem
guest_enable=YES
guest_username=sites
local_root=/home/sites/\$USER
user_sub_token=\$USER
virtual_use_local_privs=YES
user_config_dir=/etc/vsftpd_user_conf" > /etc/vsftpd.conf

# With the user_config_dir option you can specify a
# directory for per-user configuration files that
# override parts of the global settings. This is
# optional and up to you if you want to use this feature.
# Here we create the folder:
mkdir /etc/vsftpd_user_conf

# Now we must configure PAM so that it uses the
# MySQL database to authenticate our virtual FTP
# users instead of /etc/passwd and /etc/shadow.
# The PAM configuration for vsftpd is in
# /etc/pam.d/vsftpd. We make a backup of the
# original file and create a new one like this:
cp /etc/pam.d/vsftpd /etc/pam.d/vsftpd_orig
cat /dev/null > /etc/pam.d/vsftpd

cat auth required pam_mysql.so user=$S passwd=$SP  host=localhost db=vsftpd table=accounts usercolumn=username passwdcolumn=pass crypt=2 >> /etc/pam.d/vsftpd
cat account required pam_mysql.so user=$S passwd=$SP host=localhost db=vsftpd table=accounts usercolumn=username passwdcolumn=pass crypt=2 >> /etc/pam.d/vsftpd

# Restart vsftpd
/etc/init.d/vsftpd restart

Untuk buat virtual user baru dan corresponding dir
Code:
#!/bin/bash
# Create new virtual vsftpd user

p=rootpsw
u=root

echo "Enter name"
read name
echo "Enter password"
read pass

echo "INSERT INTO accounts (username, pass) VALUES('$name', PASSWORD('$pass'));" | mysql -u$u --password=$p vsftpd

mkdir /home/sites/$name
chown sites:nogroup /home/sites/$name

tes sekarang jalan apa gk ..
Code:
ftp 127.0.0.1
FOLLOW @DutaLinux
for more question and sharing about security and Opensource only

#2
mantap bang zee, jd lbih praktis setting ftp nya buat ujian akhir ane. makasih Big Grin
[shcode=This_site_xss-ed]

#3
keren juga nih bro

#4
Harus dicoba ini ...
Thanks Om Zee..






Users browsing this thread: 1 Guest(s)