设为首页 收藏本站
查看: 2978|回复: 6

[经验分享] 编译安装配置ProFTPd与添加MySQL虚拟用户

[复制链接]

尚未签到

发表于 2012-6-27 13:02:25 | 显示全部楼层 |阅读模式
在安装ProFTPd与配置MySQL虚拟用户之前,请确保你的系统已经正常运行MySQL服务器。
编译安装ProFTPd
请根据你的MySQL安装路径修改–with-includes和–with-libraries的参数。
添加ftp用户和用户组
  • groupadd -g 5500 ftpgroup
  • adduser -u 5500 -s /bin/false -d /bin/null -c "proftpd user" -g ftpgroup ftpuser

MySQL配置登录MySQL并创建数据库。
  • mysql -u root -p
  • create database ftpdb;
  • grant select, insert, update on ftpdb.* to proftpd@localhost identified by 'password';
  • use ftpdb;
  • #
  • # Table structure for table `ftpgroup`
  • #
  • CREATE TABLE ftpgroup (
  • groupname varchar(16) NOT NULL default '',
  • gid smallint(6) NOT NULL default '5500',
  • members varchar(16) NOT NULL default '',
  • KEY groupname (groupname)
  • ) TYPE=MyISAM COMMENT='ProFTP group table';
  • #
  • # Dumping data for table `ftpgroup`
  • #
  • INSERT INTO `ftpgroup` VALUES ('ftpgroup', 5500, 'ftpuser');
  • INSERT INTO `ftpgroup` VALUES ('ftpgroup', 5500, 'ftpguest');
  • CREATE TABLE `ftpquotatallies` (
  • `name` varchar(30) NOT NULL default '',
  • `quota_type` enum('user','group','class','all') NOT NULL default 'user',
  • `bytes_in_used` float NOT NULL default '0',
  • `bytes_out_used` float NOT NULL default '0',
  • `bytes_xfer_used` float NOT NULL default '0',
  • `files_in_used` int(10) unsigned NOT NULL default '0',
  • `files_out_used` int(10) unsigned NOT NULL default '0',
  • `files_xfer_used` int(10) unsigned NOT NULL default '0'
  • ) TYPE=MyISAM;
  • # --------------------------------------------------------
  • #
  • # Table structure for table `ftpuser`
  • #
  • CREATE TABLE ftpuser (
  • id int(10) unsigned NOT NULL auto_increment,
  • userid varchar(32) NOT NULL default '',
  • passwd varchar(32) NOT NULL default '',
  • uid smallint(6) NOT NULL default '5500',
  • gid smallint(6) NOT NULL default '5500',
  • homedir varchar(255) NOT NULL default '',
  • shell varchar(16) NOT NULL default '/sbin/nologin',
  • count int(11) NOT NULL default '0',
  • accessed datetime NOT NULL default '0000-00-00 00:00:00',
  • modified datetime NOT NULL default '0000-00-00 00:00:00',
  • PRIMARY KEY (id),
  • UNIQUE KEY userid (userid)
  • ) TYPE=MyISAM COMMENT='ProFTP user table';
  • INSERT INTO `ftpuser` VALUES (1, 'testaccount', 'ftppasswd', 5500, 5500, '/home/testdomain.com', '/sbin/nologin',0,'','');
  • exit;

proftpd配置文件要目录下建proftpd.conf配置文件,请在下面的代码修改好MySQL数据库登录信息。
  • ServerName "Khoosys Proftpd Server"
  • ServerType Standalone
  • ServerAdmin stephen@khoosys.net
  • # Hide as much as possible to outside users
  • ServerIdent on "Welcome to the Khoosys FTP server. Please login..."
  • DeferWelcome on
  • DefaultServer on
  • # Allow FTP resuming.
  • # Remember to set to off if you have an incoming ftp for upload.
  • AllowStoreRestart on
  • # Port 21 is the standard FTP port.
  • Port 21
  • # Umask 022 is a good standard umask to prevent new dirs and files
  • # from being group and world writable.
  • Umask 022
  • # To prevent DoS attacks, set the maximum number of child processes
  • # to 30. If you need to allow more than 30 concurrent connections
  • # at once, simply increase this value. Note that this ONLY works
  • # in standalone mode, in inetd mode you should use an inetd server
  • # that allows you to limit maximum number of processes per service
  • # (such as xinetd).
  • MaxInstances 30
  • # Set the user and group under which the server will run.
  • User ftpuser
  • Group ftpgroup
  • # To cause every FTP user to be "jailed" (chrooted) into their home
  • # directory, uncomment this line.
  • DefaultRoot ~
  • # Normally, we want files to be overwriteable.
  • AllowOverwrite on
  • # The passwords in MySQL are encrypted using CRYPT
  • SQLAuthTypes Plaintext Crypt
  • SQLAuthenticate users* groups*
  • # used to connect to the database
  • # databasename@host database_user user_password
  • SQLConnectInfo ftpdb@localhost proftpd password
  • # Here we tell ProFTPd the names of the database columns in the "usertable"
  • # we want it to interact with. Match the names with those in the db
  • SQLUserInfo ftpuser userid passwd uid gid homedir shell
  • # Here we tell ProFTPd the names of the database columns in the "grouptable"
  • # we want it to interact with. Again the names match with those in the db
  • SQLGroupInfo ftpgroup groupname gid members
  • # set min UID and GID - otherwise these are 999 each
  • SQLMinID 500
  • # create a user's home directory on demand if it doesn't exist
  • SQLHomedirOnDemand on
  • # Update count every time user logs in
  • SQLLog PASS updatecount
  • SQLNamedQuery updatecount UPDATE "count=count+1, accessed=now() WHERE userid='%u'" ftpuser
  • # Update modified everytime user uploads or deletes a file
  • SQLLog STOR,DELE modified
  • SQLNamedQuery modified UPDATE "modified=now() WHERE userid='%u'" ftpuser
  • # User quotas
  • # ===========
  • QuotaEngine on
  • QuotaDirectoryTally on
  • QuotaDisplayUnits Mb
  • QuotaShowQuotas on
  • SQLNamedQuery get-quota-limit SELECT "name, quota_type, per_session, limit_type, bytes_in_avail, bytes_out_avail, bytes_xfer_avail, files_in_avail, files_out_avail, files_xfer_avail FROM ftpquotalimits WHERE name = '%{0}' AND quota_type = '%{1}'"
  • SQLNamedQuery get-quota-tally SELECT "name, quota_type, bytes_in_used, bytes_out_used, bytes_xfer_used, files_in_used, files_out_used, files_xfer_used FROM ftpquotatallies WHERE name = '%{0}' AND quota_type = '%{1}'"
  • SQLNamedQuery update-quota-tally UPDATE "bytes_in_used = bytes_in_used + %{0}, bytes_out_used = bytes_out_used + %{1}, bytes_xfer_used = bytes_xfer_used + %{2}, files_in_used = files_in_used + %{3}, files_out_used = files_out_used + %{4}, files_xfer_used = files_xfer_used + %{5} WHERE name = '%{6}' AND quota_type = '%{7}'" ftpquotatallies
  • SQLNamedQuery insert-quota-tally INSERT "%{0}, %{1}, %{2}, %{3}, %{4}, %{5}, %{6}, %{7}" ftpquotatallies
  • QuotaLimitTable sql:/get-quota-limit
  • QuotaTallyTable sql:/get-quota-tally/update-quota-tally/insert-quota-tally
  • RootLogin off
  • RequireValidShell off

proftpd启动文件创建/etc/init.d/proftpd文件,并写入下面的代码。
  • #!/bin/sh
  • # $Id: proftpd.init,v 1.1 2004/02/26 17:54:30 thias Exp $
  • #
  • # proftpd This shell script takes care of starting and stopping
  • # proftpd.
  • #
  • # chkconfig: - 80 30
  • # description: ProFTPD is an enhanced FTP server with a focus towards \
  • # simplicity, security, and ease of configuration. \
  • # It features a very Apache-like configuration syntax, \
  • # and a highly customizable server infrastructure, \
  • # including support for multiple 'virtual' FTP servers, \
  • # anonymous FTP, and permission-based directory visibility.
  • # processname: proftpd
  • # config: /etc/proftp.conf
  • # pidfile: /var/run/proftpd.pid
  • # Source function library.
  • . /etc/rc.d/init.d/functions
  • # Source networking configuration.
  • . /etc/sysconfig/network
  • # Check that networking is up.
  • [ ${NETWORKING} = "no" ] && exit 0
  • [ -x /usr/sbin/proftpd ] || exit 0
  • RETVAL=0
  • prog="proftpd"
  • start() {
  • echo -n $"Starting $prog: "
  • daemon proftpd
  • RETVAL=$?
  • echo
  • [ $RETVAL -eq 0 ] && touch /var/lock/subsys/proftpd
  • }
  • stop() {
  • echo -n $"Shutting down $prog: "
  • killproc proftpd
  • RETVAL=$?
  • echo
  • [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/proftpd
  • }
  • # See how we were called.
  • case "$1" in
  • start)
  • start
  • ;;
  • stop)
  • stop
  • ;;
  • status)
  • status proftpd
  • RETVAL=$?
  • ;;
  • restart)
  • stop
  • start
  • ;;
  • condrestart)
  • if [ -f /var/lock/subsys/proftpd ]; then
  • stop
  • start
  • fi
  • ;;
  • reload)
  • echo -n $"Re-reading $prog configuration: "
  • killproc proftpd -HUP
  • RETVAL=$?
  • echo
  • ;;
  • *)
  • echo "Usage: $prog {start|stop|restart|reload|condrestart|status}"
  • exit 1
  • esac
  • exit $RETVAL

  • chmod 755 /etc/init.d/proftpd

之后,我们可以使用
service proftpd (start|stop|restart|reload|condrestart|status)来管理proftpd服务器。
测试proftpd之前在配置MySQL的时候,我们添加了测试帐号testaccount和密码ftppasswd,可以用这个帐号来测试proftpd是否运行正常。

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-336-1-1.html 上篇帖子: Linux vsftpd编译安装和配置允许本地用户登录FTP 下篇帖子: YUM安装ProFTPd与添加虚拟用户 安装 配置 用户

尚未签到

发表于 2013-3-13 15:38:30 | 显示全部楼层
没看完~~~~~~ 先顶,好同志

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

尚未签到

发表于 2013-5-15 19:36:39 | 显示全部楼层
男人靠的住,母猪能上树!

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

尚未签到

发表于 2013-5-16 06:27:39 | 显示全部楼层
过来看看的

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

尚未签到

发表于 2013-5-16 17:40:14 | 显示全部楼层
学习了,谢谢分享、、、

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

尚未签到

发表于 2013-5-17 07:06:08 | 显示全部楼层
找到好贴不容易,我顶你了,谢了

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

尚未签到

发表于 2013-5-17 16:28:26 | 显示全部楼层
勿以坑小而不灌,勿以坑大而灌之。

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表