I didn’t work so much about FTP server configuration but today one of our customer wanted to create limited FTP user who just gonna upload image files to server and after that another script going to fetch fetch all files for another main directory of web server. (Nobody believes each other 🙂 )
So what I learn today 🙂 There is an option in vsftpd.conf that changes all the files permisson as like chmod (looks like reverse of it mathematically)
For changing permission of files while uploading you have to find local_umask=XXX line and you have to change how ever you want and than you have to restart your vsftpd
1 |
sudo service vsftpd restart |
To understand how umask works, I explain how umask in Linux.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
➜ nwpwr@nwpwr ~ cd permission2 ➜ nwpwr@nwpwr ~/permission2 ls ➜ nwpwr@nwpwr ~/permission2 umask 000 ➜ nwpwr@nwpwr ~/permission2 touch file000 ➜ nwpwr@nwpwr ~/permission2 ls -la total 8 drwxrwxr-x 2 nwpwr nwpwr 4096 Ağu 3 13:27 . drwxr-xr-x 48 nwpwr nwpwr 4096 Ağu 3 13:27 .. -rw-rw-rw- 1 nwpwr nwpwr 0 Ağu 3 13:27 file000 ➜ nwpwr@nwpwr ~/permission2 umask 755 ➜ nwpwr@nwpwr ~/permission2 touch file755 ➜ nwpwr@nwpwr ~/permission2 ls -la total 8 drwxrwxr-x 2 nwpwr nwpwr 4096 Ağu 3 13:27 . drwxr-xr-x 48 nwpwr nwpwr 4096 Ağu 3 13:27 .. -rw-rw-rw- 1 nwpwr nwpwr 0 Ağu 3 13:27 file000 -----w--w- 1 nwpwr nwpwr 0 Ağu 3 13:27 file755 ➜ nwpwr@nwpwr ~/permission2 umask 111 ➜ nwpwr@nwpwr ~/permission2 touch file111 ➜ nwpwr@nwpwr ~/permission2 ls -la total 8 drwxrwxr-x 2 nwpwr nwpwr 4096 Ağu 3 13:28 . drwxr-xr-x 48 nwpwr nwpwr 4096 Ağu 3 13:28 .. -rw-rw-rw- 1 nwpwr nwpwr 0 Ağu 3 13:27 file000 -rw-rw-rw- 1 nwpwr nwpwr 0 Ağu 3 13:28 file111 -----w--w- 1 nwpwr nwpwr 0 Ağu 3 13:27 file755 ➜ nwpwr@nwpwr ~/permission2 umask 655 ➜ nwpwr@nwpwr ~/permission2 touch file 655 ➜ nwpwr@nwpwr ~/permission2 ls -la total 8 drwxrwxr-x 2 nwpwr nwpwr 4096 Ağu 3 13:28 . drwxr-xr-x 48 nwpwr nwpwr 4096 Ağu 3 13:28 .. -----w--w- 1 nwpwr nwpwr 0 Ağu 3 13:28 655 -----w--w- 1 nwpwr nwpwr 0 Ağu 3 13:28 file -rw-rw-rw- 1 nwpwr nwpwr 0 Ağu 3 13:27 file000 -rw-rw-rw- 1 nwpwr nwpwr 0 Ağu 3 13:28 file111 -----w--w- 1 nwpwr nwpwr 0 Ağu 3 13:27 file755 |
So as you see we created files which has different permissions(If your eyes work well, you will realise that I’m liar) with touch command.
The reason why 111 permission and 000 permission has THE SAME permission is exception of Linux1.
And also you can change globally by changing home/anyuser/.profile or /etc/profile file for ssh option that means you can create your files different than -rw-rw-r– or 022
check also:
1 2 |
umask umask -S |