sudo的-A选项是一个非常有用的选项,它可以使得sudo命令不需要每次输密码,它的作用原文如下:
Normally, if sudo requires a password, it will read it from
the current terminal. If the -A (askpass) option is specified, a (possibly graphical) helper program is executed to read the user's password and output the
password to the standard output. If the SUDO_ASKPASS environment variable is set, it specifies the path to the helper program. Otherwise, the value specified by the
askpass option in sudoers(5) is used.
即通过指定一个helper proram用于提供密码
我只试过用第一种方法:
1.先写了个简单的C程序,只有一行:printf("密码\n");
\n必须要加。编译,获得可执行代码。
2.指定SUDO_ASKPASS为上面的可执行代码路径。
3.使用sudo命令,格式为:sudo -A XXXX
阅读(4934) | 评论(0) | 转发(0) |