VSFTPD with Samba Server on Centos
Installing VSftpd FTP Server on CentOS
VSftpd is an FTP server for Linux.
Install the VSftpd Server
Type the following command to install the VSftpd FTP Server:
[root@centos7 ~]# yum install vsftpd
Backup the default configuration file ‘vsftpd.conf’:
[root@centos7 ~]# cp /etc/vsftpd/vsftpd.conf /etc/vsftpd/vsftpd.conf.back
We also need to install the FTP client, so that we can connect to an FTP server:
[root@centos7 ~]# yum install ftp
Configure the VSftpd Server
Once the VSftpd Server is installed, you can adjust the basic configuration.
Once the VSftpd Server is installed, you can adjust the basic configuration.
Anonymous FTP is allowed by default. Set the anonymous_enable=NO to secure your server.
Open the configuration file:
vi /etc/vsftpd/vsftpd.conf
Make the following changes:
Option Description
anonymous_enable=NO Disable anonymous login
local_enable=YES Enable local users
write_enable=YES Give FTP users permissions to write data
connect_from_port_20=NO Port 20 need to be turned off. It makes VSftpd run less privileged
chroot_local_user=YES Chroot everyone
Check vsftpd.conf man pages, for all configuration options.
man vsftpd.conf
Add at the end of file
[root@centos7 ~]# local_root=/var/ftp
[root@centos7 ~]# useradd nafees
[root@centos7 ~]# passwd nafees
[root@centos7 ~]# useradd -d '/var/ftp' -s /sbin/nologin nafees
[root@centos7 ~]# mkdir -p /var/ftp
[root@centos7 ~]# chown -R nafees '/var/ftp'
[root@centos7 ~]# chmod 775 '/var/ftp'
[root@centos7 ~]#groupadd ftpusers
[root@centos7 ~]# usermod -G ftpusers nafees
[root@centos7 ~]# firewall-cmd --permanent --zone=public --add-port=21/tcp
[root@centos7 ~]# firewall-cmd --permanent --add-service=ftp
[root@centos7 ~]# firewall-cmd --reload
[root@centos7 ~]# chkconfig --levels 235 vsftpd on[root@centos7 ~]# sudo firewall-cmd --reload[root@centos7 ~]# service vsftpd start
[root@centos7 ~]# systemctl restart vsftpd
[root@centos7 ~]# systemctl enable vsftpd
open browser and type server ip in my case ip is ftp://172.16.13.199
after login will show like this
Option Description
anonymous_enable=NO Disable anonymous login
local_enable=YES Enable local users
write_enable=YES Give FTP users permissions to write data
connect_from_port_20=NO Port 20 need to be turned off. It makes VSftpd run less privileged
chroot_local_user=YES Chroot everyone
local_umask=022 Set umask to 022, to make sure that all the files (644) and folders (755) you upload, get the proper permissions
Check vsftpd.conf man pages, for all configuration options.
man vsftpd.conf
[root@centos7 ~]# local_root=/var/ftp
[root@centos7 ~]# useradd nafees
[root@centos7 ~]# passwd nafees
[root@centos7 ~]# useradd -d '/var/ftp' -s /sbin/nologin nafees
[root@centos7 ~]# mkdir -p /var/ftp
[root@centos7 ~]# chown -R nafees '/var/ftp'
[root@centos7 ~]# chmod 775 '/var/ftp'
[root@centos7 ~]#groupadd ftpusers
[root@centos7 ~]# usermod -G ftpusers nafees
[root@centos7 ~]# firewall-cmd --permanent --zone=public --add-port=21/tcp
[root@centos7 ~]# firewall-cmd --permanent --add-service=ftp
[root@centos7 ~]# firewall-cmd --reload
[root@centos7 ~]# chkconfig --levels 235 vsftpd on[root@centos7 ~]# sudo firewall-cmd --reload[root@centos7 ~]# service vsftpd start
[root@centos7 ~]# systemctl restart vsftpd
[root@centos7 ~]# systemctl enable vsftpd
open browser and type server ip in my case ip is ftp://172.16.13.199
Install Sama Server now
[root@centos7 ~]# yum -y install samba samba-client samba-common[root@centos7 ~]# mv /etc/samba/smb.conf /etc/samba/smb.conf.bak[root@centos7 ~]# vi /etc/samba/smb.conf
[global]
workgroup = WORKGROUP
server string = Samba Server %v
netbios name = srvr1
security = user
map to guest = bad user
dns proxy = no
[ftp]
path = /var/ftp/
browsable = yes
writable = yes
valid users =nafees,root
guest ok = no
read only = no
workgroup = WORKGROUP
server string = Samba Server %v
netbios name = srvr1
security = user
map to guest = bad user
dns proxy = no
[ftp]
path = /var/ftp/
browsable = yes
writable = yes
valid users =nafees,root
guest ok = no
read only = no
[root@centos7 ~]# firewall-cmd --permanent --zone=public --add-service=samba
[root@centos7 ~]# firewall-cmd --reload
Now Configure user password for samba access
[root@centos7 ~]# smbpasswd -a nafees
[root@centos7 ~]# systemctl enable smb.service
[root@centos7 ~]# systemctl enable nmb.service
[root@centos7 ~]# systemctl restart smb.service
[root@centos7 ~]# systemctl restart nmb.service
Note:- if there is any problem accessing samba then disable Selinux
[root@centos7 ~]# vi /etc/selinux/config
Now access from network
After login show like blew
I just uploaded a test file to this folder for testing purpose now refresh the ftp browser link
Every thing is working fine ...
No comments:
Post a Comment