Operating System - HP-UX
1834501 Members
2234 Online
110068 Solutions
New Discussion

Re: Password for text file on HP-UX 11.11

 
David Nguyen
New Member

Password for text file on HP-UX 11.11

Hi,

How do I create a password for text file on HP-UX 11.11?

Thanks,

David
4 REPLIES 4
A. Clay Stephenson
Acclaimed Contributor

Re: Password for text file on HP-UX 11.11

You can use the UNIX crypt command. Man crypt for details.

You can also lauch vi with the -x option.

vi -x myfile
It will then prompt you for a key used to encrypt/decrypt myfile.
If it ain't broke, I can fix that.
David Nguyen
New Member

Re: Password for text file on HP-UX 11.11

Thanks for the help,
I have more questions as follows:

1. Can an entire directory be password protected? If yes, what commands that can be used to achieve this?

2. Can an existing text file be password protected?

Thanks,


David
Geoff Wild
Honored Contributor

Re: Password for text file on HP-UX 11.11

You can also use pgp to "lock" files.

To update the file you must do the following:

Become root
cd to the /yourdir directory
Enter the command:
pgp pwd_list.pgp

Enter the pass phrase when prompted
A new plain text file named pwd_list will be created. Edit this file and make your changes. You can use your text editor of choice (vi, emacs)
After the changes have been made re-encrypt the file using the command:
pgp -cw pwd_list

When prompted, enter/reenter the pass phrase
Answer y for yes to overwrite the existing pwd_list.pgp file
Test that you can see your changes by using the command:
pgp -m pwd_list.pgp

Enter the pass phrase when prompted
After viewing the file enter the command:
blank_term


Rgds...Geoff
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
Mel Burslan
Honored Contributor

Re: Password for text file on HP-UX 11.11

David,

There is not protection of directory levels. As a matter of fact, the protection Clay described is not a password protection in the sense you presume. It is altering the contents of the file by encryption depending on the key value you provide. You will still be able to access the file even if it is encrypted but will make no sense out of the contents of the file. Whereas, in real password protection, the file will not be accesible to you at all.

The way to accomplish this is using ownership and group memberships of the people who can read/write/execute a file. If this is not granular enough for your purpose, there is a whole new can of worms called ACLs to help you accomplish your goal but, you have to be really, really know about them upto your eyeballs or you will lock even yourself out of your files and find yourself in a mess that clean up would nearly be impossible.

To protect an existing file, assuming named as file.txt:

crypt mypassword file.prot

now your file is encrypted and written into file.prot At this point it is your responsibility to delete the clear text version.

to recover the clear text file back:

crypt mypassword file.txt

or

open your file with vi as follows:

vi -x file.txt

when asked for key, enter the password you want to use
modify the file by at least a single character then go to command mode (by hitting escape) and type
:wq!

next time you want to access this file, use the same command and same password, otherwise you will see garbled character soup instead of your original text.

HTH

________________________________
UNIX because I majored in cryptology...