[英]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.