How to set a password to protect a directory and its contents in unix? - unix

May I know how to set a password to protect a directory and its contents in unix? Eg. It will prompt user to type in a password to access the directory.
I tried to do it with enfs:
mkdir ~/.encrypted ~/encrypted
encfs ~/.encrypted ~/encrypted
And but it shows "encfs: command not found".

Related

Oracle UTL_FILE.fremove (or frename) permission denied

We have a oracle 12.1.0.2 installation on Linux, we have a procedure that read files from a folder, process data and writes file to another folder, and we have all permission required on the folder, so it works up to this point.
The problem arise when we try to remove the source file from the starting folder, because the database user has all the the rights on the folder but not on the specific file! Users and suppliers can upload file in this folder via ftp and we couldn't find way to replicate folder permission, I attach a couple of screenshots, please help.
Oracle error is ORA-29283: Invalid file operation
Folder Rights
File Rights
During creation of the files, the permission -rwxr-xr-x might be granted by issuing :
$ chmod 755 test_ftp.xlsx or $ chmod a+x test_ftp.xlsx for related file to be able to be deleted.

What is the reason that kernel need execution permission to traverse in directories?

In *nix it is being said that, everything is considered as file (even it is a directory). Then, If directory is a file which does not contain any binary or any executable data, but only contain inode number and file name, then what is the need of "execute" permission for directory file ???
Here i attached screen-shot, that showing directory has execute permission
also i have seen(on another site) directory's Execute permission means:
"Execute bit = You can make this directory your working directory".
but just making "directory as our working directory" is it the only one reason to provide "Execute" permission for directory ??
please can any one provide the exact reason for "execute" permission.

Changing owner directly from cp

At a final test in college, one of the subjects was : " Find a way to copy file /etc/sudoers in home of user "student". The resulted file has to be owned by "student". There are not allowed permission modifications on the source or destination file. "
I've tried everything but couldn't find a way.
Being student, you can paste the file into your directory:
cat /etc/sudoers > /home/student/your_sudo
The file your_sudo will be created having your_user as owner. Note that you might need to use sudo cat /etc/sudoers, because this file can just have 770 permissions.

Symfony2 and Ubuntu 11.10 permission folder and file

When i open some files(Symfony2.0) with netbeans, this say me:Cannot Lock read Only
i must click right mouse and set every folder the permission to "read and write"
this is big problem because i must set every folder and file.....
how i can fix this my problem permission?
you need add write permissions to the whole folder/subfolders and files.
For example:
chmod -R u+w foldername
-R is to do it for sub-folders and all files (recursive)
u - is for the owner (your user)
+w - is to add write permissions
Perhaps you created symfony2 files using root where netbeans uses user permissions which is currently logged in. Make sure your files/folders belong to user not to the root
If your user is different from the user the server is running as (apache, httpd, www-data for instance), then you must either add yourself to the server group and chmod all the files so group permissions are set to read and write, or chown all the files to you (chown -R user:user) and add your server user to your group.
Also, dont forget to set proper permissions on the cache/ and log/ folders
(they must be writable by the command line user when you do a cache:clear and also writable by the server user)
For more info you can check the "setting up permissions" paragraph on the Installing Symfony Chapter of the Symfony book here:
http://symfony.com/doc/current/book/installation.html

How does Encfs work?

I cannot understand the idea behind Encfs. Even ready example, offered by my Ubuntu, does not work for me:
encfs ~/crypt ~/.crypt
There is an error:
unable to locate a mount point
Should I initialize the files somehow? What is wrong?
As I use encfs since 2009 and until now every day, I will make a quick how to :
What you need for make it work ?
fuse and encfs only, they can be found directly in your package management
Debian : apt-get install encfs
Fedora : yum install encfs
Gentoo : emerge encfs
...
(select only encfs will install dependencies automatically)
How do I create a crypted directory ?
If you want to use encfs with your user (no root), you must add fuse on the group of this one first. Open a terminal and log in root :
adduser youruser fuse
replace youruser by your.
Once add, kill and restart X or just reboot your computer.
Now open a terminal (in user $) :
groups
If you see fuse, then you can create the directory now by this command :
encfs /home/youruser/.crypt/ /home/youruser/crypt
.crypt and crypt directory must not exist, if they exist, delete them or choice another path
The first time, it will display as follow :
The directory "/home/youruser/.crypt/" does not exist. Should it be
created? (y,n) y
The directory "/home/youruser/crypt" does not exist.
Should it be created? (y,n) y
Please choose from one of the following
options: enter "x" for expert configuration mode, enter "p" for
pre-configured paranoia mode, anything else, or an empty line will
select standard mode. ?> p
New Encfs Password:
Verify Encfs Password:
As showed, answer -> first y | second y | third p
Once created, the directory crypt is mounted (by default), add files inside crypt directory. For make them unreadable :
fusermount -u /home/youruser/crypt
This will unmount the directory crypt, all the file inside "disappear" and can be found encrypted on the directory .crypt :
ls /home/youruser/.crypt/
Will display something like (3 files on this example) :
0WoRsjyzZHI,Un-198TRY-dU 91rj264Z09Jcz7XZ4sbDeYfd KpJTDI2TVUEFHTkksqxPT9xu
For get back your crypted file readable, do :
encfs /home/youruser/.crypt /home/youruser/crypt
Will output a prompt requiring your password
How do I backup the crypted file, and open them to another computer / server
Be aware, except your encrypted file, you absolutely need to backup the file encfs6.xml which contain your encoded password and his salt generation.
http://en.wikipedia.org/wiki/Salt_%28cryptography%29
this file can be found :
/home/youruser/.crypt/.encfs6.xml
Best way to backup your crypted data in a proper way :
tar cvzf CryptedBackup.tar.gz /home/youruser/.crypt/
With the backup, on your other computer/server just unpack it to the /home/user/ and create the mount point (mkdir /home/user/crypt) and it will work.
Careful, if you lost your password, or if your encfs6.xml is missing, is no way to get back your encrypted
It will give you this error if both of the conditions are trues:
~/crypt is not a directory (e.g. is missing, or a non-directory called ~/crypt already exists), and
~/crypt cannot be created by encfs (mkdir would fail, e.g. permissions issues, or a non-directory called ~/crypt already exists)
See the source code at http://code.google.com/p/encfs/source/browse/trunk/encfs/main.cpp?spec=svn27&r=27
Maybe you're mixing up the directories. ~/crypt and ~/.crypt must both be existing directories where the first parameter to encfs will be the store, where the encrypted files will be stored by encfs and the second parameter is the place where you want to place your files you want to be encrypted.
See also here for a guide on how to set up and use encfs.

Resources