LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 936|回复: 4

如何实现gpg自动输入password?

[复制链接]
发表于 2007-6-12 10:57:04 | 显示全部楼层 |阅读模式
我想用gpg来加密文件,希望能作到不用用户参与自动加密。

一般的用法为:

  1. gpg -c <file_name>
复制代码

回车后gpg会提示输入密码,这时候必须手动输入两次,加密完成。

如何能不需要用户参与,通过I/O重定向之类的功能实现呢?

我试着用


  1. gpg -c $filename <<END
  2. 123456
  3. 123456
  4. END
复制代码


但是不能工作。
发表于 2007-6-12 14:02:03 | 显示全部楼层
  1. gpg --batch --passphrase xxx
复制代码

man gpg 看 passphrase 相关
回复 支持 反对

使用道具 举报

 楼主| 发表于 2007-6-12 14:48:04 | 显示全部楼层
我想用对称算法去加密,楼上的方法不行阿。
回复 支持 反对

使用道具 举报

发表于 2007-6-14 22:28:27 | 显示全部楼层
有人知道吗?555 我也想知道哇
回复 支持 反对

使用道具 举报

发表于 2007-6-15 08:58:40 | 显示全部楼层
gpg --passphrase-file passfile -c filename

将从指定的文件中读取密码,只读取第一行


man gpg 有如下内容:

       --passphrase-repeat n
              Specify  how  many  times  gpg will request a new passphrase be repeated.  This is useful for helping memorize a passphrase.  Defaults to 1
              repetition.

       --passphrase-fd n
              Read the passphrase from file descriptor n. Only the first line will be read from file descriptor n. If you use 0  for  n,  the  passphrase
              will be read from stdin. This can only be used if only one passphrase is supplied.

       --passphrase-file file
              Read  the  passphrase from file file. Only the first line will be read from file file. This can only be used if only one passphrase is sup-
              plied. Obviously, a passphrase stored in a file is of questionable security if other users can read this file. Don't use this option if you
              can avoid it.

       --passphrase string
              Use string as the passphrase. This can only be used if only one passphrase is supplied. Obviously, this is of very questionable security on
              a multi-user system. Don't use this option if you can avoid it.
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表