linux文件用密码加密_在未加密的情况下,如何在Linux / Unix上用密码保护文件夹?

linux文件用密码加密_在未加密的情况下,如何在Linux / Unix上用密码保护文件夹?

linux文件用密码加密

linux文件用密码加密_在未加密的情况下,如何在Linux / Unix上用密码保护文件夹?

If you do not need or want to encrypt files on your computer but would like to stop casual snooping, then what is the best method for password protecting your folders on Linux/Unix? Today’s SuperUser Q&A post has helpful answers to a curious reader’s question.

如果您不需要或不想对计算机上的文件进行加密,但是想停止随意的监听,那么在Linux / Unix上保护文件夹密码的最佳方法是什么? 今天的《超级用户问答》帖子对好奇的读者的问题提供了有用的答案。

Today’s Question & Answer session comes to us courtesy of SuperUser—a subdivision of Stack Exchange, a community-driven grouping of Q&A web sites.

今天的“问答”环节由SuperUser提供,它是Stack Exchange的一个分支,该社区是由社区驱动的Q&A网站分组。

Photo courtesy of Nathan Meijer (Flickr).

图片由Nathan Meijer(Flickr)提供

问题 (The Question)

SuperUser reader Zane Woodard wants to know how to password protect a folder on Linux/Unix without encryption:

超级用户阅读器Zane Woodard想知道如何使用密码对Linux / Unix上的文件夹进行加密而不进行加密:

I have searched around quite a bit for either a built-in feature or program to do this, but had no luck. I want to password protect a folder, but do not want to encrypt it.

我已经搜索了很多内置功能或程序来执行此操作,但是没有运气。 我想用密码保护文件夹,但不想加密它。

The security of the contents of the folder is not important, the password would just act as a deterrent to somebody attempting to access the contents of the folder from my computer. Think of it like a password lock on a computer, if you were to remove the hard-drive, you could easily take all the files the user had, but the password is still a deterrent to people accessing the contents of the drive.

文件夹内容的安全性并不重要,密码只会对试图从我的计算机访问文件夹内容的人起到威慑作用。 可以将其视为计算机上的密码锁,如果要卸下硬盘驱动器,则可以轻松获取用户拥有的所有文件,但是该密码仍然对访问驱动器内容的人员起到了威慑作用。

Two main reasons for not using encryption here are:

这里不使用加密的两个主要原因是:

  • Decreased performance for opening files.

    打开文件的性能降低。
  • Encryption prevents the contents from being indexed/searchable.

    加密可防止对内容进行索引/搜索。

Is anybody aware of a solution?

有人知道解决方案吗?

Is there an easy solution that Zane could use to password protect his folder?

Zane可以使用一种简单的解决方案来密码保护他的文件夹吗?

答案 (The Answer)

SuperUser contributors R Schultz and Bodo Thiesen have the answer for us. First up, R Schultz:

超级用户贡献者R Schultz和Bodo Thiesen为我们找到了答案。 首先,舒尔茨(R Schultz):

The easiest way would be to change the permissions of the files so that they are not readable by anyone other than the owner. Once that is done, a user would have to either log in as you (which should require a password) or sudo as root (which should also require a password). To change the permissions, simply use the following command on any files you do not want others to have access to.

最简单的方法是更改​​文件的权限,以便所有者以外的任何人都无法读取它们。 完成此操作后,用户将必须以您的身份登录(这需要输入密码)或以sudo作为根用户(也需要输入密码)登录。 要更改权限,只需在您不希望其他人访问的任何文件上使用以下命令。

  • chmod og-rwx filename

    chmod og-rwx文件名

This assumes that when you are not at your computer, your screen is locked and there is a password for your account as well as the root account.

这是假设您不在计算机上时,屏幕已锁定,并且您的帐户以及根帐户都有密码。

Followed by the answer from Bodo Thiesen:

随后是Bodo Thiesen的回答:

Create a new user for these protected files and/or directories. Then replace $newuser with the new user account name:

为这些受保护的文件和/或目录创建一个新用户。 然后将$ newuser替换为新的用户帐户名:

  • chown $newuser filename directoryname

    chown $ newuser文件名目录名
  • chmod og-rwx filename directoryname

    chmod og-rwx文件名目录名

This way, the files and directories are safe even if you do not log out and have your screen unlocked for some reason.

这样,即使您不注销并出于某种原因使屏幕解锁,文件和目录也是安全的。



Have something to add to the explanation? Sound off in the comments. Want to read more answers from other tech-savvy Stack Exchange users? Check out the full discussion thread here.

有什么补充说明吗? 在评论中听起来不错。 是否想从其他精通Stack Exchange的用户那里获得更多答案? 在此处查看完整的讨论线程

翻译自: https://www.howtogeek.com/203816/how-do-you-password-protect-a-folder-on-linuxunix-without-encryption/

linux文件用密码加密