Hello Friends, Today we are going to configure FTP Server(vsftpd) for multiptle user with different home directory. In previous post we have already learned how to configure FTP Server(vsftpd) on Google Cloud Compute Engine. If you not already read that post and not configured ftp server then click here to read that post before going through this post. To configure FTP Server(vsftpd) for multiple user with different home directory we just need to follow below steps:-
Step 1: Create two users named as ftpuser1 and ftpuser2 using below command.
1 2 |
sudo adduser ftpuser1 sudo adduser ftpuser2 |
Note: It will ask you for password, just enter your desired password and it will also ask for user information i.e. full name, room number, work phone etc, you can skip it by just pressing enter.
Step 2: Configure FTP Server (vsftpd) by updating vsftpd.conf configuration file using below command.
1 |
sudo nano /etc/vsftpd.conf |
Above command will open vsftpd.conf file in nano editor and then we need to paste below lines at the end of the file.
1 2 |
# setup virtual users config folder user_config_dir=/etc/vsftpd_user_config_dir/ |
Note: We need to restart vsftpd every time we do changes in vsftpd.conf configuration file and also checking status is good practice using below command
1 2 |
sudo systemctl restart vsftpd sudo systemctl status vsftpd |
Step 3: Setup home directory
To configure home folder, create the /etc/vsftpd_user_config_dir/ folder and create two files with the exact same name of the two users:
1 |
sudo mkdir /etc/vsftpd_user_config_dir/ |
1 |
sudo nano /etc/vsftpd_user_config_dir/ftpuser1 |
The above nano command will create new file and open it automatically and then we’ll define home folder for first user in the file in following way:
1 2 |
local_root=/home/ftpuser/ftpuser1 write_enable=YES |
now we’ll create another file for second user same way and edit it but this time home folder will be “/home/ftpuser/ftpuser2”
1 |
sudo nano /etc/vsftpd_user_config_dir/ftpuser2 |
1 2 |
local_root=/home/ftpuser/ftpuser2 write_enable=YES |
Step 4: Create home directory for both user using below command
1 2 |
sudo mkdir /home/ftpuser/ftpuser1 sudo mkdir /home/ftpuser/ftpuser2 |
Step 5: Create group and add user into group using below command
1 2 3 4 |
sudo groupadd ftpusers sudo usermod -a -G ftpusers ftpuser sudo usermod -a -G ftpusers ftpuser1 sudo usermod -a -G ftpusers ftpuser2 |
Step 6: Change ownership of “/home/ftpuser” directory to ftpusers group and making “/home/ftpuser” directory writable by group using below command so that directory is accessible and writable by all users of group
1 2 |
sudo chown -R root:ftpusers /home/ftpuser sudo chmod -R g+w /home/ftpuser |
And we are done!
Thanks for stopping by
Please don’t forget to share if it helped
Comments