{"id":2219,"date":"2015-06-13T21:15:17","date_gmt":"2015-06-13T13:15:17","guid":{"rendered":"http:\/\/ixyzero.com\/blog\/?p=2219"},"modified":"2015-06-13T21:15:17","modified_gmt":"2015-06-13T13:15:17","slug":"%e8%b7%a8%e5%b9%b3%e5%8f%b0%e7%9a%84%e5%8a%a0%e8%a7%a3%e5%af%86%e6%96%b9%e6%a1%88","status":"publish","type":"post","link":"https:\/\/ixyzero.com\/blog\/archives\/2219.html","title":{"rendered":"\u8de8\u5e73\u53f0\u7684\u52a0\u89e3\u5bc6\u65b9\u6848"},"content":{"rendered":"<h6>\u7f18\u8d77\uff1a<\/h6>\n<p>\u5728Linux\u4e0a\u52a0\u5bc6\u6587\u4ef6\uff0c\u4f20\u9001\u5230\u767e\u5ea6\u4e91\u4e0a\uff0c\u7136\u540e\u518d\u4ece\u767e\u5ea6\u4e91\u4e0a\u4e0b\u8f7d\u6587\u4ef6\uff1b\u4f46\u662f\u4e4b\u524d\u7528\u7684ccrypt\u547d\u4ee4\u5728Windows\u4e0a\u6ca1\u6709\u4e00\u4e2a\u6bd4\u8f83\u597d\u7684\u56fe\u5f62\u5316\/\u7ec8\u7aef\u89e3\u5bc6\u65b9\u6848\u3002<\/p>\n<h6>\u641c\u7d22\u5173\u952e\u5b57\uff1a<\/h6>\n<ul>\n<li>encrypt file on linux and decrypt on windows<\/li>\n<li>use password when tar<\/li>\n<\/ul>\n<h6>\u53c2\u8003\u89e3\u7b54\uff1a<\/h6>\n<p>\u7528gpg\u6216aes\u662f\u6bd4\u8f83\u9760\u8c31\u548c\u65b9\u4fbf\u7684\uff1b\u9664\u4e86\u5728Linux\u4e0a\u52a0\u5bc6\u65b9\u4fbf\u4e4b\u5916\uff0c\u5728Windows\u4e0a\u4e5f\u6709\u7ecf\u8fc7\u9a8c\u8bc1\u7684GUI\u8f6f\u4ef6\u63d0\u4f9b\u89e3\u5bc6\uff0c\u633a\u597d\u7684\u3002<\/p>\n<h6>\u53c2\u8003\u94fe\u63a5\uff1a<\/h6>\n<ul>\n<li><a href=\"http:\/\/security.stackexchange.com\/questions\/4411\/simple-way-to-encrypt-files-on-linux-and-decrypt-on-windows\">http:\/\/security.stackexchange.com\/questions\/4411\/simple-way-to-encrypt-files-on-linux-and-decrypt-on-windows<\/a><\/li>\n<li><a href=\"http:\/\/gpg4win.org\/\">http:\/\/gpg4win.org\/<\/a><\/li>\n<li>=<\/li>\n<li><a href=\"http:\/\/superuser.com\/questions\/381849\/cross-platform-file-encryption-tool\">http:\/\/superuser.com\/questions\/381849\/cross-platform-file-encryption-tool<\/a><\/li>\n<li><a href=\"http:\/\/www.cyberciti.biz\/tips\/linux-how-to-encrypt-and-decrypt-files-with-a-password.html\">http:\/\/www.cyberciti.biz\/tips\/linux-how-to-encrypt-and-decrypt-files-with-a-password.html<\/a><\/li>\n<li><a href=\"https:\/\/www.aescrypt.com\/download\/\">https:\/\/www.aescrypt.com\/download\/<\/a><\/li>\n<li>=<\/li>\n<li><a href=\"http:\/\/xmodulo.com\/how-to-create-encrypted-zip-file-on-linux.html\">http:\/\/xmodulo.com\/how-to-create-encrypted-zip-file-on-linux.html<\/a><\/li>\n<li><a href=\"http:\/\/stackoverflow.com\/questions\/24734101\/use-tar-to-compress-file-tar-gz-with-password\">http:\/\/stackoverflow.com\/questions\/24734101\/use-tar-to-compress-file-tar-gz-with-password<\/a><\/li>\n<li><a href=\"http:\/\/superuser.com\/questions\/370389\/how-do-i-password-protect-a-tgz-file-with-tar-in-unix\">http:\/\/superuser.com\/questions\/370389\/how-do-i-password-protect-a-tgz-file-with-tar-in-unix<\/a><\/li>\n<li><a href=\"http:\/\/superuser.com\/questions\/272879\/how-to-use-password-protection-with-the-linux-tar-command\">http:\/\/superuser.com\/questions\/272879\/how-to-use-password-protection-with-the-linux-tar-command<\/a><\/li>\n<\/ul>\n<p>==<\/p>\n<p>\u56e0\u4e3a\u9700\u8981\u7528\u811a\u672c\u81ea\u52a8\u52a0\u5bc6\u4f20\u8f93\u7684\u9644\u4ef6\uff0c\u786e\u5b9a\u7684\u52a0\u89e3\u5bc6\u65b9\u6848\u4e3agpg\uff0c\u5728Linux\u7cfb\u7edf\u4e0a\u53ea\u8981\u88c5\u4e86gpg\u7684\u8bdd\uff0c\u4e0d\u8bba\u662f\u52a0\u5bc6\u8fd8\u662f\u89e3\u5bc6\u90fd\u5f88\u7b80\u5355\uff0c\u4f46\u6211\u8fd9\u91cc\u9700\u8981\u7684\u662f\u4ece\u6587\u4ef6\u4e2d\u8bfb\u53d6\u5b57\u7b26\u4e32\u4f5c\u4e3a\u5bc6\u94a5\u8fdb\u884c\u5bf9\u79f0\u52a0\u5bc6\uff0c\u6240\u4ee5\u67e5\u770b\u4e86\u4e00\u4e0bgpg\u7684manual\u624b\u518c\uff0c\u5728\u7f51\u4e0a\u641c\u7d22\u4e86\u4e4b\u540e\u81ea\u5df1\u8fdb\u884c\u6d4b\u8bd5\uff0c\u5f97\u5230\u5b9e\u9645\u7ecf\u9a8c\u5982\u4e0b\uff1a<\/p>\n<pre class=\"lang:default decode:true\"># gpg --dump-options | grep pass\n--passphrase\n--passphrase-fd\n--passphrase-file\n--passphrase-repeat<\/pre>\n<p>\u4f46\u662f\u6211\u4f7f\u7528\u5176\u4e2d\u7684 &#8211;passphrase-file \u9009\u9879\u65f6\uff0c\u8fd8\u4f1a\u63d0\u793a\u9700\u8981\u7ee7\u7eed\u8f93\u5165\u5bc6\u7801\uff08\u7cfb\u7edf\u73af\u5883\u4e3a\uff1aUbuntu 14.04.2 LTS i686\uff09<\/p>\n<p><a href=\"http:\/\/unix.stackexchange.com\/questions\/60213\/gpg-asks-for-password-even-with-passphrase\">http:\/\/unix.stackexchange.com\/questions\/60213\/gpg-asks-for-password-even-with-passphrase<\/a><\/p>\n<p>=-=<\/p>\n<p>I am in your exact same boat (it worked on Fedora but not Ubuntu). Here is an apparent work around I discovered:<\/p>\n<p>echo your_password | gpg &#8211;passphrase-fd 0 your_file.gpg<\/p>\n<p>Explanation: Passing\u00a00\u00a0causes\u00a0&#8211;passphrase-fd\u00a0to read from STDIN rather than from a file. So, piping the passphrase will get\u00a0&#8211;passphrase-fd\u00a0to accept your specified password string.<\/p>\n<p>=-=<\/p>\n<p>\u6240\u4ee5\u6700\u540e\u9000\u800c\u6c42\u5176\u6b21\u7528\u7684\u662f &#8220;&#8211;passphrase-fd 0&#8221; \u8fd9\u4e2a\u65b9\u6cd5\u66ff\u4ee3\uff08\u76f4\u63a5\u5c06\u5bc6\u7801\u6587\u4ef6\u7684\u5185\u5bb9cat\u51fa\u6765\uff0c\u7136\u540e\u7ba1\u9053\u4f20\u4e0b\u53bb\uff0c\u6548\u679c\u548c\u624b\u52a8\u8f93\u5165\u662f\u4e00\u6837\u7684\uff09<\/p>\n<p>Ps\uff1a\u6211\u6d4b\u8bd5\u4e86 &#8211;passphrase-file \u548c &#8211;batch &#8211;no-tty &#8211;yes \u90fd\u4e0d\u884c\u3002<\/p>\n<pre class=\"lang:default decode:true\">cat $passphrase | gpg --passphrase-fd 0 -c ${bak_path}\/bak_${date_yyyymmdd}.zip\n#\u82e5\u547d\u4ee4\u6b63\u786e\u6267\u884c\uff0c\u5219\u4f1a\u8fd4\u56de0\uff0c\u540c\u65f6\u751f\u6210\u6587\u4ef6${bak_path}\/bak_${date_yyyymmdd}.zip.pgg<\/pre>\n<p>\u76f4\u63a5\u4f7f\u7528\u4e0a\u9762\u7684\u547d\u4ee4\uff0c\u6216\u662f\u624b\u52a8\u6267\u884c\u5305\u542b\u8be5\u547d\u4ee4\u7684\u811a\u672c\u662f\u53ef\u4ee5\u6b63\u5e38\u6267\u884c\u7684\uff0c\u4f46\u662f\uff0c\u653e\u5165crontab\u4e4b\u540e\u5c31\u4f1a\u62a5\u9519\uff1a<\/p>\n<p>gpg: cannot open tty `\/dev\/tty&#8217;: No such device or address<\/p>\n<p>\u53bb\u7f51\u4e0a\u641c\u7d22\u4e86\u4e4b\u540e\u53d1\u73b0\u6709\u4e0d\u5c11\u4eba\u4e5f\u9047\u5230\u4e86\u8fd9\u4e2a\u95ee\u9898\uff0c\u539f\u56e0\u4ec0\u4e48\u7684\u5c31\u4e0d\u6df1\u7a76\u4e86\uff0c\u8bf4\u4e0b\u89e3\u51b3\u529e\u6cd5\u5427\uff1a<\/p>\n<p><strong>\u589e\u52a0&#8221;&#8211;no-tty&#8221;\u548c&#8221;&#8211;batch&#8221;\u9009\u9879<\/strong><\/p>\n<pre class=\"lang:default decode:true\">cat $passphrase | gpg --no-tty --batch --passphrase-fd 0 -c ${bak_path}\/bak_${date_str}.zip<\/pre>\n<p>==<\/p>\n<h5>bpcs_uploader\u7684\u4f7f\u7528<\/h5>\n<h6>\u641c\u7d22\u5173\u952e\u5b57\uff1a<\/h6>\n<ul>\n<li>vps baidu.com api<\/li>\n<\/ul>\n<h6>\u53c2\u8003\u94fe\u63a5\uff1a<\/h6>\n<ul>\n<li><a href=\"https:\/\/www.haiyun.me\/archives\/859.html\">https:\/\/www.haiyun.me\/archives\/859.html<\/a><\/li>\n<li><a href=\"http:\/\/developer.baidu.com\/console#manage\/apilist!appid=6055048\">http:\/\/developer.baidu.com\/console#manage\/apilist!appid=6055048<\/a><\/li>\n<li><a href=\"https:\/\/github.com\/oott123\/bpcs_uploader\/\">https:\/\/github.com\/oott123\/bpcs_uploader\/<\/a><\/li>\n<li><a href=\"https:\/\/www.v2ex.com\/t\/193374\" target=\"_blank\">\u4e2a\u4eba\u7528\u4ec0\u4e48\u7f51\u76d8\u597d\uff0c\u6c42\u63a8\u8350 &#8211; V2EX<\/a><\/li>\n<li>=<\/li>\n<li><a href=\"http:\/\/mm.hanbobo.net\/2015\/04\/08\/Upload-YouTube-Video-from-VPS-to-Baiduyun\/\">http:\/\/mm.hanbobo.net\/2015\/04\/08\/Upload-YouTube-Video-from-VPS-to-Baiduyun\/<\/a><\/li>\n<li><a href=\"http:\/\/blog.cunss.com\/?p=170\" target=\"_blank\">\u5229\u7528\u767e\u5ea6\u7f51\u76d8\u5907\u4efdVPS<\/a><\/li>\n<li><a href=\"http:\/\/oott123.github.io\/bpcs_uploader\/\">http:\/\/oott123.github.io\/bpcs_uploader\/<\/a><\/li>\n<li><a href=\"http:\/\/yanzhuang.net\/2978.html\">http:\/\/yanzhuang.net\/2978.html<\/a><\/li>\n<li><a href=\"http:\/\/zhiwei.li\/text\/2013\/09\/curl%E8%B0%83%E7%94%A8%E7%99%BE%E5%BA%A6%E7%BD%91%E7%9B%98api%E5%88%86%E7%89%87%E4%B8%8A%E4%BC%A0%E5%A4%A7%E6%96%87%E4%BB%B6\/\">curl\u8c03\u7528\u767e\u5ea6\u7f51\u76d8API\u5206\u7247\u4e0a\u4f20\u5927\u6587\u4ef6<\/a><\/li>\n<li><a href=\"http:\/\/www.unixdo.com\/Unix_Linux\/bpcs_uploader.html\">http:\/\/www.unixdo.com\/Unix_Linux\/bpcs_uploader.html<\/a><\/li>\n<li><a href=\"http:\/\/www.freehao123.com\/baiduyun-linux-vps\/\">http:\/\/www.freehao123.com\/baiduyun-linux-vps\/<\/a><\/li>\n<li><a href=\"http:\/\/yangjunwei.com\/a\/1339.html\">http:\/\/yangjunwei.com\/a\/1339.html<\/a><\/li>\n<\/ul>\n<p>=EOF=<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u7f18\u8d77\uff1a \u5728Linux\u4e0a\u52a0\u5bc6\u6587\u4ef6\uff0c\u4f20\u9001\u5230\u767e\u5ea6\u4e91\u4e0a\uff0c\u7136\u540e\u518d\u4ece\u767e\u5ea6\u4e91\u4e0a\u4e0b\u8f7d\u6587\u4ef6\uff1b\u4f46\u662f\u4e4b\u524d\u7528\u7684ccrypt\u547d\u4ee4\u5728Win [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[23,11,25,12,20],"tags":[527,528,529,230],"class_list":["post-2219","post","type-post","status-publish","format-standard","hentry","category-knowledgebase-2","category-linux","category-security","category-tools","category-windows","tag-aes","tag-ccrypt","tag-encrypt","tag-gpg"],"views":2937,"_links":{"self":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts\/2219","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/comments?post=2219"}],"version-history":[{"count":0,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts\/2219\/revisions"}],"wp:attachment":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/media?parent=2219"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/categories?post=2219"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/tags?post=2219"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}