Pages

Monday, November 17, 2014

Linux FTP Multiple users directory change and permission set and FTP server




Linux FTP multiple users directory change and permission set
=====================================================

Let we a vsftp sever in CentOS.
A user khan created and need to change ftp login path to /home/FTP-Uploads/


adduser khan
passwd khan

usermod -g root khan
chmod g=rw -R /home/FTP-Uploads/
chown -R khan /home/FTP-Uploads/

vi   /etc/passwd

khan:x:511:0::/home/FTP-Uploads/:/sbin/nologin

## Adding another user name "tayab" and give him to "FTP-Uploads" directory permission
## Multiple user in permission for one Directory
Multiples users should be in same group ..
Here I add both user "khan" and "tayab" to root group
by
usermod -g root tayab
vi /etc/group
root:x:0:khan,shakkhor


setfacl -m u:tayab:rwx -R FTP_Uploads

===============================

Sample FTP Server  
==================
vi /etc/vsftpd/vsftpd.conf
=================
anonymous_enable=NO
local_enable=YES
write_enable=YES
local_umask=022
dirmessage_enable=YES
xferlog_enable=YES
connect_from_port_20=YES
xferlog_file=/var/log/vsftpd.log
xferlog_std_format=YES
ftpd_banner=Welcome to Tayab-Khan's FTP service.
listen=YES
pasv_min_port=2121
pasv_max_port=2142
pam_service_name=vsftpd
userlist_enable=YES
tcp_wrappers=YES
======================
IPtables for FTP::
-A INPUT -p tcp -m state --state NEW -m tcp -m multiport --dports 2121:2142 -j ACCEPT
-A INPUT -s 10.10.10.0/24 -p tcp -m state --state NEW -m tcp --dport 20 -j ACCEPT
-A INPUT -s 10.10.10.0/24 -p tcp -m state --state NEW -m tcp --dport 21 -j ACCEPT
================================

Some Commands 
----------------------------
to find without hashed lines   root#   egrep -v '^(#|$)'  /etc/vsftpd/vsftpd.conf 
or                                            root#   grep -E -v '^(#|$)'  /etc/vsftpd/vsftpd.conf

to find and send outputs to another file..
 root#  sed -e '/^[ ]*#/d' -e '/^[ ]*;/d' -e '/^$/d' //etc/vsftpd/vsftpd.conf > /root/tayab-ftp-active-lines.txt

=======================================================

File and Directory permission issues
--------------------------------------------
To change all the directories to 755 (drwxr-xr-x):

find /home/tayab/lampp/htdocs -type d -exec chmod 755 {} \;

To change all the files to 644 (-rw-r--r--):

find /home/tayab/lampp/htdocs -type f -exec chmod 644 {} \;

-----------------------------------------------------------------



No comments:

Post a Comment