Welcome to Linux Forums!

With a comprehensive Linux Forum, information on various types of Linux software and many Linux Reviews articles, we have all the knowledge you need a click away, or accessible via our knowledgeable members.

Linux Forum ArticlesLinux ForumsLinux Forum DownloadsLinux HostsFree MagazinesJobs
Home|Register|FAQ|Member List|Calendar|Unanswered Posts|Forum Rules|Today's Posts|Advanced Search|
SEARCH FOR IN
Go Back   Linux Forums > Your Distro > Ubuntu Help
Reload this Page Any way to encrypt a file so that no one can decrypt it.
Linux Forums
Linux Forums
Welcome To The Linux Forums!
Welcome to Linux Forums. We pride ourselves in being one of the largest Linux communities on the web, we encourage you to REGISTER on our forums and participate in the community. There are over 150,000 members ready to answer your questions. JOINING US today will allow you to make new posts, get support, send messages to other members and submit downloads to our downloads directory and many other great features!

Ubuntu Help Discussion and help about Ubuntu, Kubuntu, Xubuntu, and all the Ubuntu family

Reply
 
Thread Tools Display Modes
Old 08-04-2007   #1 (permalink)
Just Joined!
 
Join Date: Jul 2006
Posts: 6
Any way to encrypt a file so that no one can decrypt it.

Hi,

I guess what I am trying to do is LOCK A DOOR and THROW away the keys. Reason is I would like to encrypt a HIGH security file where many others have access to it on the server. I would like to encrypt it and put it in a cron for it to run daily. However, I would not like anyone to decrypt the file or view its contents as lots of passwords etc must reside there. So has anyone come across this problem and if so what is the approach you took.

Cheers,
Nathan.
thusi02 is offline   Reply With Quote
Old 08-04-2007   #2 (permalink)
Linux Enthusiast
 
Join Date: Apr 2004
Location: UK
Posts: 579
I suspect encryption is not the right thing to use here. You're basically moving the problem from people being able to access the file being executed to people being able to access the key file that needs to be used to decrypt the file before it can be run.

I'd suggest creating a separate user to run the file. Change the permissions so only that user can read and execute the file.

If that's not enough you can do more, but it would help if you could let us know what kind of file it is and what it does.

Let us know how you get on,

Chris...
__________________
DRM keeps an honest user loyal
kakariko81280 is offline   Reply With Quote
Old 08-07-2007   #3 (permalink)
Just Joined!
 
Join Date: Jul 2006
Posts: 6
Hi kakariko81280,

You see the problem is that many of the users have sudo access on the machine. Also most of them are involved in the project as well. The problem is that we need to make a database connection to grab some of the data to populate our internal database. However, this db requires us to put our personal username/passwords to authenticate. Meaning we do not get a role account on the database. Thus as you can see, we do not want to put our account information into the script in clear text. As also most of the members have sudo access and will be aware of the process. So I would like to somehow put this account information in the script and encrypt it somehow so that others this includes the team members cannot read the file. However we should be able to remake the file to put in another person credential if one leaves the team. The main fact is that no one should be able to decrypt the file to read it in anyway as the file will contain the password.

Any thoughts?
Thank you for your time and effort.
Cheers,

Nathan.
thusi02 is offline   Reply With Quote
Old 08-07-2007   #4 (permalink)
Super Moderator
 
devils casper's Avatar
 
Join Date: Jun 2006
Location: Chandigarh, INDIA
Posts: 18,411
You can use openssl to encrypt files.
To encrypt a file:
Code:
openssl des3 -salt -in infile.txt -out encryptedfile.txt
To decrypt the file:
Code:
openssl des3 -d -salt -in encryptedfile.txt -out normalfile.txt
Do not specify the same file as input and output on encryption. I have noticed weird effects on OS X (it eats the file). Remove the -in * stuff if you want to pipe data into it (e.g. a tarred folder). Omit the -out * stuff if you want it to pipe data out on STDOUT.
__________________
New Users: Read This First


devils casper is offline   Reply With Quote
Old 08-07-2007   #5 (permalink)
Just Joined!
 
Join Date: Jul 2006
Posts: 6
Hi devils_casper,

Thank you for your reply. However, solution does not work as well. I have looked into this however, since there is a way to decrypt the file this will not work. Basically I want a one way ticket. I want to be able to encrypt the file and have it execute. However, I do not want there to be anyway of decrypting the file. So I want a member of the team to put their password into the file and encrypt the file and be safe that no one else is going to come along that has sudo access on the system to be able to decrypt the file. This is where the dilemma is.

Any thoughts?

Cheers,
Nathan.
thusi02 is offline   Reply With Quote
Old 08-07-2007   #6 (permalink)
Super Moderator
 
devils casper's Avatar
 
Join Date: Jun 2006
Location: Chandigarh, INDIA
Posts: 18,411
Quote:
So I want a member of the team to put their password into the file and encrypt the file and be safe that no one else is going to come along that has sudo access on the system to be able to decrypt the file. This is where the dilemma is.
Whenever you encrypt any file with openssl, it asks for password. You can assing any password. No body can decrypt that file, not even root user unless you disclose the password assigned during encryption.
__________________
New Users: Read This First


devils casper is offline   Reply With Quote
Old 08-07-2007   #7 (permalink)
Linux Enthusiast
 
Join Date: Apr 2004
Location: UK
Posts: 579
I don't want to be pessimistic, but I don't think there is a way to achieve exactly what you are after.

An encrypted script would require decryption before it could be run. Because you want the script to be run by cron you need to put everything needed to decrypt the script on the server.

You can't prevent a root user who is aware of the process from performing the same steps as the cron job to recover the plain text and therefore the passwords you are trying to protect.

Can you set up a separate user on the database that only has access to the data that will be pulled by the script? If so then it shouldn't matter if your users can use that login because they will only be able to access data that is made available on a daily basis anyway.

Another option would be to write a simple application instead of a script. The compilation process would obfuscate the steps somewhat, but it depends on how good your users are at analysing compiled programs and what tools they have available.

Let us know how you get on,

Chris...
__________________
DRM keeps an honest user loyal
kakariko81280 is offline   Reply With Quote
Old 08-07-2007   #8 (permalink)
Just Joined!
 
Join Date: Jul 2006
Posts: 6
Hi devils_casper,

Thank you for clarifying that. That helps quite a bit.

Follow up question: So now that I encrypted this python library file. When I import it into a python script it complains about the encoding type. Do you by chance know how to get around this? Do I have to provide the decryption password in the script which kinda defeats the purpose again. Please let me know.

Thank you
Regards,
Nathan.
thusi02 is offline   Reply With Quote
Old 08-07-2007   #9 (permalink)
Just Joined!
 
Join Date: Jul 2007
Posts: 18
I'm no expert on this, but the point of encryption is to be able to decrypt.

If you don't want specific users to be able to decrypt the file because you fear they are going to learn other peoples passwords that are stored in the file, but at the same time you want a program to be able to write data to the file, you still have to store the key somewhere because the program will need to decrypt the file in order to write and read meaningful data to it. Like someone said, you can pull the users' permissions to the file, and then write an su program to modify the encrypted file, but you'd then have to pull the users' sudo access to avoid them circumventing the permissions you set up.

Anyway the point is your problem lies in your users' root access
GreyGrey is offline   Reply With Quote
Old 08-07-2007   #10 (permalink)
Bigtomrodinator
 
bigtomrodney's Avatar
 
Join Date: Nov 2004
Location: Sunny South-East of Ireland
Posts: 5,190
Surely you can be more discriminating in the /etc/sudoers file? Grant users only the root permission for what they need?
__________________
Registered Linux user #378740
New members read here / Forum Rules
#linuxforums on irc.freenode.net
bigtomrodney is offline   Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off
 

Similar Threads
Thread Thread Starter Forum Replies Last Post
The problem that I made mencoder source to static library. Jeon, Chang-Min Linux Programming & Scripting 5 07-09-2005 11:01 PM
Enemy territory Game runs but appears to crash mattlaver Gaming / Games / Multimedia / Entertainment 7 03-14-2005 04:28 PM
will Mplayer will playing windows media player format too ?? hasan Linux Newbie 30 10-02-2003 03:20 AM
KDE basics with some Tips and Tricks flw Linux Tutorials, HOWTO's & Reference Material 0 07-17-2003 02:14 AM
Securing Linux 101: Reasonable Steps flw Linux Tutorials, HOWTO's & Reference Material 0 07-13-2003 04:34 AM

Free Magazines
Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe
Systems Management News, the newspaper for IT systems administration and data center managers!
Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe
The Enterprise Newsweekly
eWeek is the essential technology information source for builders of e-business.
subscribe
Oracle Magazine
Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe
Total Telecom
Total Telecom is "The Economist of the communications industry".
subscribe
More free magazines »



All times are GMT. The time now is 04:24 AM.




© 2000 - 2008 - All Rights Reserved - Property of  MAS Media

Content Relevant URLs by vBSEO 3.2.0