本文介绍了如何在RedHat的bash脚本中输入密码而不用切换到root用户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想通过在代码中指定密码而不是输入密码来在RedHat上的bash脚本中切换为root用户.
I want to switch to root user in bash script on RedHat by specifying the password in code rather than entering it.
任何帮助将不胜感激.
谢谢
推荐答案
在脚本中以纯文本格式存储密码不是一个好主意.您可以使用 visudo
编辑 sudoers
文件,并允许用户使用 sudo
而不使用密码来运行命令.
It's not a good idea to store passwords in plain text in a script. You can use visudo
to edit the sudoers
file and allow users to run a command using sudo
without using a password.
这篇关于如何在RedHat的bash脚本中输入密码而不用切换到root用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!