[英]Is there a way to include the input in the bash file so that I will not type the input required in the command line every time I run the bash script
我正在使用 bash 腳本通過 Ubuntu 服務器在實時站點上執行自動部署。
其中一條線具有以下內容:
scp build.zip user_name@ip_address:/path/to/releases/$release
一旦 Ubuntu 執行此命令,它將要求我在命令行中輸入密碼,例如:
Enter passphrase for key '/home/user_name/.ssh/id_rsa':
有沒有辦法在 bash 文件中包含輸入,這樣我每次運行 bash 腳本時就不會在命令行中輸入密碼?
您可以使用另一個文件來編寫所需的輸入行。
./your_script.sh < your_input_file.txt
但這似乎不是最好的主意,我寧願嘗試避免在每個子命令中輸入的需要。
您可以通過運行此命令並設置新的空白密碼來永久刪除id_rsa
密鑰上的密碼:
ssh-keygen -p
對於通用解決方案,您可以使用expect
腳本以編程方式驅動終端 session 並與之交互。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.