我想从hadoopmaster到hduser.当我在终端上这样做时,我做:
su - hduser
然后我要求输入密码,然后我输入密码,然后进入hduser.如何在shell脚本中执行相同操作而不必担心密码?我尝试了sudoers文件方法,我把它放在:
root ALL=(ALL:ALL) ALL
hduser ALL=(ALL:ALL) ALL
hadoopmaster ALL=(ALL:ALL) NOPASSWD: /bin/su hduser
(here I tried different combinations of the line with and without the '-' and also
with and without /bin)
我做了这个,当我做su hduser或su – hduser时,它再次提示我输入密码.我该怎么办?
解决方法:
你不要在sudoers文件中使用“su”,你需要使用“sudo”.所以,你需要一个命令行,如:
sudo su – hduser
只要你在sudoers文件中有适当的行,你会想要你想要的.像这样的一行:
hadoopmaster ALL =(ALL:ALL)NOPASSWD:su – hduser
应该做的伎俩.
标签:linux,ubuntu,ubuntu-12-04,sudo,sudoers
来源: https://codeday.me/bug/20190725/1532193.html