質問

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)

enter image description here

役に立ちましたか?

解決

男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 つあります。

  1. ldapadd 標準入力からパスワードを読み取ります。
  2. ldapadd 現在の TTY からパスワードを直接読み取ります。

最初のケースでは、次のようなものを使用するだけで十分です echo 'MySecretPassword' | ldapadd -h localhost -D "cn=admin,dc=sysadmin1,dc=hioa,dc=no" -W -x -f /etc/ldap/base.ldif. 。2 番目の方法は、次のようなツールが必要なので、より複雑です。 期待する. 。まず単純なリダイレクトが機能するかどうかを確認してください。

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top