簡體   English   中英

如何輸入密碼然后按Enter bash / Chef進行Nginx配置

[英]How to enter password then hit enter bash/Chef for Nginx config

我正在使用Nginx設置基本身份驗證,我想通過一本食譜來做到這一點。 我目前擁有的方法是設置了一個bash塊,除此之外沒有其他東西。 我不確定是否有辦法使用廚師/紅寶石輸入我需要的東西,或者我需要進行重擊。

命令

sudo htpasswd -c /etc/nginx/.htpasswd <username>

打擊塊

bash 'create nginx login pasword' do
  user 'root'
  cwd '/tmp'
  code <<-EOH
  sudo htpasswd -c /etc/nginx/.htpasswd <username1>
  sudo htpasswd /etc/nginx/.htpasswd <username2>
  sudo htpasswd /etc/nginx/.htpasswd <username3>
  EOH
  action :run
end

有完整的食譜來創建文件並添加用戶。

https://supermarket.chef.io/cookbooks/htpasswd

# add user "foo" with password "bar" to "/etc/nginx/htpassword" with the default md5 type.
htpasswd "/etc/nginx/htpassword" do
  user "foo"
  password "bar"
end

有沒有理由不使用它?

htpasswrd輸出相對靜態的輸出。 在您的工作站上運行這些文件,然后使用現有的機密管理層(Hashicorp Vault,chef-vault等)分發文件數據。 然后使用file資源將其寫出。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM