From 987841774279a1301c9ba83e1583418885fc22ad Mon Sep 17 00:00:00 2001 From: ch-cn Date: Wed, 24 May 2017 17:28:25 +0800 Subject: [PATCH] translated --- ...to Password Protect a Vim File in Linux.md | 157 ------------------ ...to Password Protect a Vim File in Linux.md | 155 +++++++++++++++++ 2 files changed, 155 insertions(+), 157 deletions(-) delete mode 100644 sources/tech/20170509 How to Password Protect a Vim File in Linux.md create mode 100644 translated/tech/20170509 How to Password Protect a Vim File in Linux.md diff --git a/sources/tech/20170509 How to Password Protect a Vim File in Linux.md b/sources/tech/20170509 How to Password Protect a Vim File in Linux.md deleted file mode 100644 index 616d03b89b..0000000000 --- a/sources/tech/20170509 How to Password Protect a Vim File in Linux.md +++ /dev/null @@ -1,157 +0,0 @@ -How to Password Protect a Vim File in Linux -============================================================ -ch-cn translating - - Download Your Free eBooks NOW - [10 Free Linux eBooks for Administrators][16] | [4 Free Shell Scripting eBooks][17] - -[Vim][5] is a popular, feature-rich and highly-extensible [text editor for Linux][6], and one of its special features is support for encrypting text files using various crypto methods with a password. - -In this article, we will explain to you one of the simple Vim usage tricks; password protecting a file using Vim in Linux. We will show you how to secure a file at the time of its creation as well as after opening it for modification. - -**Suggested Read:** [10 Reasons Why You Should Use Vim Editor in Linux][7] - -To install the full version of Vim, simply run this command: - -``` -$ sudo apt install vim #Debian/Ubuntu systems -$ sudo yum install vim #RHEL/CentOS systems -$ sudo dnf install vim #Fedora 22+ -``` - -Read Also: [Vim 8.0 Is Released After 10 Years – Install on Linux][8] - -### How to Password Protect a Vim File in Linux - -Vim has a `-x` option which enables you to use encryption when creating files. Once you run the [vim command][9]below, you’ll be prompted for a crypt key: - -``` -$ vim -x file.txt -Warning: Using a weak encryption method; see :help 'cm' -Enter encryption key: ******* -Enter same key again: ******* -``` - -If the crypto key matches after entering it for the second time, you can proceed to modify the file. - - [![Vim File Password Protected](https://www.tecmint.com/wp-content/uploads/2017/05/Vim-File-Password-Protected-File.png)][10] - -Vim File Password Protected - -Once your done, press `[Esc]` and `:wq` to save and close the file. The next time you want to open it for editing, you’ll have to enter the crypto key like this: - -``` -$ vim file.txt -Need encryption key for "file.txt" -Warning: Using a weak encryption method; see :help 'cm' -Enter encryption key: ******* -``` - -In case you enter a wrong password (or no key), you’ll see some junk characters. - - [![Vim Content Encrypted](https://www.tecmint.com/wp-content/uploads/2017/05/Vim-Content-Encrypted.png)][11] - -Vim Content Encrypted - -#### Setting a Strong Encryption Method in Vim - -Note: There is a warning indicating that a weak encryption method has been used to protect the file. Next, we’ll see how to set a strong encryption method in Vim. - - [![Weak Encryption on Vim File](https://www.tecmint.com/wp-content/uploads/2017/05/Weak-Encryption-on-Vim-File.png)][12] - -Weak Encryption on Vim File - -To check the set of cryptmethod(cm), type (scroll down to view all available methods): - -``` -:help 'cm' -``` - -##### Sample Output - -``` - *'cryptmethod'* *'cm'* -'cryptmethod' 'cm' string (default "zip") -global or local to buffer |global-local| -{not in Vi} -Method used for encryption when the buffer is written to a file: -*pkzip* -zip PkZip compatible method. A weak kind of encryption. -Backwards compatible with Vim 7.2 and older. -*blowfish* -blowfish Blowfish method. Medium strong encryption but it has -an implementation flaw. Requires Vim 7.3 or later, -files can NOT be read by Vim 7.2 and older. This adds -a "seed" to the file, every time you write the file -options.txt [Help][RO] -``` - -You can set a new cryptomethod on a Vim file as shown below (we’ll use blowfish2 in this example): - -``` -:setlocal cm=blowfish2 -``` - -Then press `[Enter]` and `:wq` to save the file. - - [![Set Strong Encryption on Vim File](https://www.tecmint.com/wp-content/uploads/2017/05/Set-Strong-Encryption-on-Vim-File.png)][13] - -Set Strong Encryption on Vim File - -Now you should not see the warning message when you open the file again as shown below. - -``` -$ vim file.txt -Need encryption key for "file.txt" -Enter encryption key: ******* -``` - -You can also set a password after opening a Vim text file, use the command`:X` and set a crypto pass like shown above. - -Check out some of our useful articles on Vim editor. - -1. [Learn Useful Vim Editor Trips and Tricks in Linux][1] - -2. [8 Useful Vim Editor Tricks for Every Linux User][2] - -3. [spf13-vim – The Ultimate Distribution for Vim Editor][3] - -4. [How to Use Vim Editor as Bash IDE in Linux][4] - -That’s all! In this article, we explained how to password protect a file via the [Vim text editor in Linux][14]. - -Always remember to appropriately secure text files that could contain secret info such as usernames and passwords, financial account info and so on, using strong encryption and a password. Use the feedback section below to share any thoughts with us. - --------------------------------------------------------------------------------- - -作者简介: - -Aaron Kili is a Linux and F.O.S.S enthusiast, an upcoming Linux SysAdmin, web developer, and currently a content creator for TecMint who loves working with computers and strongly believes in sharing knowledge. - ------------------- - -via: https://www.tecmint.com/password-protect-vim-file-in-linux/ - -作者:[Aaron Kili ][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://www.tecmint.com/author/aaronkili/ -[1]:https://www.tecmint.com/learn-vi-and-vim-editor-tips-and-tricks-in-linux/ -[2]:https://www.tecmint.com/how-to-use-vi-and-vim-editor-in-linux/ -[3]:https://www.tecmint.com/spf13-vim-offers-vim-plugins-vim-editor/ -[4]:https://www.tecmint.com/use-vim-as-bash-ide-using-bash-support-in-linux/ -[5]:https://www.tecmint.com/vi-editor-usage/ -[6]:https://www.tecmint.com/best-open-source-linux-text-editors/ -[7]:https://www.tecmint.com/reasons-to-learn-vi-vim-editor-in-linux/ -[8]:https://www.tecmint.com/vim-8-0-install-in-ubuntu-linux-systems/ -[9]:https://www.tecmint.com/linux-command-line-editors/ -[10]:https://www.tecmint.com/wp-content/uploads/2017/05/Vim-File-Password-Protected-File.png -[11]:https://www.tecmint.com/wp-content/uploads/2017/05/Vim-Content-Encrypted.png -[12]:https://www.tecmint.com/wp-content/uploads/2017/05/Weak-Encryption-on-Vim-File.png -[13]:https://www.tecmint.com/wp-content/uploads/2017/05/Set-Strong-Encryption-on-Vim-File.png -[14]:https://www.tecmint.com/vi-editor-usage/ -[15]:https://www.tecmint.com/author/aaronkili/ -[16]:https://www.tecmint.com/10-useful-free-linux-ebooks-for-newbies-and-administrators/ -[17]:https://www.tecmint.com/free-linux-shell-scripting-books/ diff --git a/translated/tech/20170509 How to Password Protect a Vim File in Linux.md b/translated/tech/20170509 How to Password Protect a Vim File in Linux.md new file mode 100644 index 0000000000..21ae3a5113 --- /dev/null +++ b/translated/tech/20170509 How to Password Protect a Vim File in Linux.md @@ -0,0 +1,155 @@ +怎样在 Linux 中对 Vim 文件进行密码保护 +============================================================ + + 现在下载你的免费电子书籍 - [给管理员的 10 本免费的 Linux 电子书籍][16] | [4 本免费的 Shell 脚本电子书籍][17] + +[Vim][5] 是一种流行的、功能丰富的和高度可扩展的 [Linux 文本编辑器][6],它的重要功能之一便是支持用各种带密码的加密方法来加密文本文件。 + +本文中,我们将向你介绍一种简单的 Vim 使用技巧;在 Linux 中使用 Vim 对文件进行密码保护。我们将向你展示如何让一个文件在它创建的时侯以及为了修改目的而被打开了之后获得安全防护。 + +**建议阅读:** [你应该在 Linux 中使用 Vim 编辑器的 10 个原因][7] + +要安装 Vim 完整版,只需运行这些命令: + +``` +$ sudo apt install vim #Debian/Ubuntu 系统 +$ sudo yum install vim #RHEL/CentOS 系统 +$ sudo dnf install vim #Fedora 22+ +``` +参阅: [十年后 Vim 8.0 发布了– 在 Linux 上安装][8] + +### 怎样在 Linux 中对 Vim 文件进行密码保护 + +Vim 有个 `-x` 选项,这个选项能让你在创建文件时用它来加密。一旦你运行下面的 [vim 命令][9],你会被提示输入一个密钥: + +``` +$ vim -x file.txt +警告:正在使用弱加密方法;参见 :help 'cm' +输入加密密钥:******* +再次输入相同密钥:******* +``` + +如果第二次输入的密钥无误,你就能进去修改此文件了。 + + [![Vim File Password Protected](https://www.tecmint.com/wp-content/uploads/2017/05/Vim-File-Password-Protected-File.png)][10] + +被密码保护的 Vim 文件 + +等你修改好之后,摁 `[Esc]` 和键入 `:wq` 来保存及关闭文件。下次你想打开它编辑一下,你就必须像这样去输入密钥: + +``` +$ vim file.txt +需要 "file.txt" 的加密密钥 +警告:正在使用弱加密方法;参见 :help 'cm' +输入密钥:******* +``` + +假设你输了一个错误的密码(或者没输密码),你会看到一些垃圾字符。 + + [![Vim Content Encrypted](https://www.tecmint.com/wp-content/uploads/2017/05/Vim-Content-Encrypted.png)][11] + +Vim 中的加密内容 + +#### 在 Vim 中设置一种强加密方法 + +注意:有条告警信息暗示一种弱加密方法已被用于保护文件。那么接下来,我们来看看怎么在 Vim 中设置一种强加密方法。 + + [![Weak Encryption on Vim File](https://www.tecmint.com/wp-content/uploads/2017/05/Weak-Encryption-on-Vim-File.png)][12] + +Vim 中文件弱加密 + +为了查看 crytmethod(cm) 集,键入(向下滚动可查看所有可用的方法): + +``` +:help 'cm' +``` + +##### 输出样例 + +``` + *'cryptmethod'* *'cm'* +'cryptmethod' 'cm' string (默认 "zip") +global or local to buffer |global-local| +{not in Vi} +当缓冲区写进文件中所用的方法: +*pkzip* +zip PkZip 兼容法。 一种弱加密方法。 +与 Vim 7.2 及更老版本后向兼容。 +*blowfish* +blowfish 河豚法。 中级强度加密方法但有实现上 +的瑕疵。需要 Vim 7.3 及以上版本,用它加密的文件不 +能被 Vim 7.2 及更老版本读取。它会添加一个 “种子”, +每次你对这个文件写操作时…… +options.txt [帮助][只读] +``` + +你可以像如下所示的那样给一个 Vim 文件设置个新的 cryptomethod(加密方法)(本例中我们用 blowfish2 加密方法) + +``` +:setlocal cm=blowfish2 +``` + +然后键入 `[Enter]` 和 `:wq` 保存下文件。 + + [![Set Strong Encryption on Vim File](https://www.tecmint.com/wp-content/uploads/2017/05/Set-Strong-Encryption-on-Vim-File.png)][13] + +对 Vim 文件设置强加密 + +现在你再打开下示的文件时应该就看不到那条警告信息了。 + +``` +$ vim file.txt +需要 "file.txt" 的加密密钥 +输入加密密钥:******* +``` + +你也可以在打开 Vim 文件之后来设置密码,用 `:X` 命令就能像上面所示的那样去设置一个密码关卡。 + +可以看看我们其他的关于 Vim 编辑器的有用的文章。 + +1. [在 Linux 中学习有用的 Vim 编辑器的旅行与技巧][1] + +2. [给每个 Linux 用户的 8 种有用的 Vim 编辑器技巧][2] + +3. [spf13-vim – Vim 编辑器的顶级发行版][3] + +4. [怎样在 Linux 种把 Vim 编辑当作 Bash IDE 来用][4] + +本文到这里就结束了!文章中我们介绍了怎么通过 Linux 下的 Vim 文本编辑器来给一个文件做加密防护。 + +永远记住要用强加密方式及密码来适当的保护那些可能包含了诸如用户名及密码、财务账户信息等等机密信息的文本文件。 + +-------------------------------------------------------------------------------- + +作者简介: + +Aaron Kili 是一个 Linux 和 F.O.S.S(Free and Open-Source Software,自由及开放源代码软件)爱好者,未来的 Linux 系统管理员、web 开发人员,目前是 TecMint 的内容创作者,他喜欢用电脑工作,且崇尚分享知识。 + +------------------ + +via: https://www.tecmint.com/password-protect-vim-file-in-linux/ + +作者:[Aaron Kili ][a] +译者:[ch-cn](https://github.com/ch-cn) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://www.tecmint.com/author/aaronkili/ +[1]:https://www.tecmint.com/learn-vi-and-vim-editor-tips-and-tricks-in-linux/ +[2]:https://www.tecmint.com/how-to-use-vi-and-vim-editor-in-linux/ +[3]:https://www.tecmint.com/spf13-vim-offers-vim-plugins-vim-editor/ +[4]:https://www.tecmint.com/use-vim-as-bash-ide-using-bash-support-in-linux/ +[5]:https://www.tecmint.com/vi-editor-usage/ +[6]:https://www.tecmint.com/best-open-source-linux-text-editors/ +[7]:https://www.tecmint.com/reasons-to-learn-vi-vim-editor-in-linux/ +[8]:https://www.tecmint.com/vim-8-0-install-in-ubuntu-linux-systems/ +[9]:https://www.tecmint.com/linux-command-line-editors/ +[10]:https://www.tecmint.com/wp-content/uploads/2017/05/Vim-File-Password-Protected-File.png +[11]:https://www.tecmint.com/wp-content/uploads/2017/05/Vim-Content-Encrypted.png +[12]:https://www.tecmint.com/wp-content/uploads/2017/05/Weak-Encryption-on-Vim-File.png +[13]:https://www.tecmint.com/wp-content/uploads/2017/05/Set-Strong-Encryption-on-Vim-File.png +[14]:https://www.tecmint.com/vi-editor-usage/ +[15]:https://www.tecmint.com/author/aaronkili/ +[16]:https://www.tecmint.com/10-useful-free-linux-ebooks-for-newbies-and-administrators/ +[17]:https://www.tecmint.com/free-linux-shell-scripting-books/