gpt4 book ai didi

linux - 写入要求输入密码的标准输入

转载 作者:太空宇宙 更新时间:2023-11-04 11:11:15 25 4
gpt4 key购买 nike

我正在编写一个 bash 脚本来配置 openldap 并为用户和组添加 ldif 脚本。

如何从 bash 脚本中写入密码?

这是我在询问密码时运行的脚本:

ldapadd -h localhost -D "cn=admin,dc=sysadmin1,dc=hioa,dc=no" -W -x -f /etc/ldap/base.ldif

编辑:

我试过了,并创建了一个 passwd.txt 文件,密码为:

ldapadd -h localhost -D "cn=admin,dc=sysadmin1,dc=hioa,dc=no" -W -x -y'passwd.txt' -f /etc/ldap/base.ldif

但是得到这个错误:

Warning: Password file passwd.txt is publicly readable/writeable
ldap_bind: Invalid credentials (49)

enter image description here

最佳答案

man ldapadd.

-W
Prompt for simple authentication. This is used instead of specifying the password on the command line.

-w passwd
Use passwd as the password for simple authentication.
-y passwdfile
Use complete contents of passwdfile as the password for simple authentication.

看来您正在寻找 -w-y 选项,而不是 -W

关于linux - 写入要求输入密码的标准输入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23029562/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com