パスワードを要求する標準入力に書き込みます
-
21-12-2019 - |
質問
openldapを構成し、ユーザーとグループを含むldifスクリプトを追加するbashスクリプトに取り組んでいます。
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)
解決
男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
のオプションを探しています。
他のヒント
可能性は 2 つあります。
ldapadd
標準入力からパスワードを読み取ります。ldapadd
現在の TTY からパスワードを直接読み取ります。
最初のケースでは、次のようなものを使用するだけで十分です echo 'MySecretPassword' | ldapadd -h localhost -D "cn=admin,dc=sysadmin1,dc=hioa,dc=no" -W -x -f /etc/ldap/base.ldif
. 。2 番目の方法は、次のようなツールが必要なので、より複雑です。 期待する. 。まず単純なリダイレクトが機能するかどうかを確認してください。
所属していません StackOverflow