大网数据广告活动
服务器运维问答

executing a command without password prompt or root

· 52CE 我爱测

For the sake of writing a script, I'd like my minikube-role-user to execute the command minikube tunnel without a password prompt, without switching user to root, be it by su or temporarily by sudo, or permanently with visudo. I …

问题原文

原帖链接 · Dylan · CC BY-SA 4.0

For the sake of writing a script, I'd like my minikube-role-user to execute the command minikube tunnel without a password prompt, without switching user to root, be it by su or temporarily by sudo, or permanently with visudo.

I have tried giving my minikube-role-user the executable permission for, and ownership of, the executable /bin/minikube and /usr/bin/minikube but the password prompt persists. I don't think the minikube executable prompts for a password itself, I think it just executes a second executable that I don't have permission for and need to discover so I can get permission for it. I suspect this because the minikibe tunnel command doesn't prompt for a password immediately, does print some stdout before and after prompting for the password, and other minikube commands don't prompt for a password. I thought this hypothetical second executable maybe nftables because minikube tunnel may write an nftables rule, but giving my minikube-role-user ownership permissions of nftables did not get rid of the password prompt.

已采纳解答

原帖链接 · criztovyl · CC BY-SA 4.0

For Linux minikube tunnel uses hard-coded sudo under-the-hood, as such you won't get around visudo / adjusting sudoers.

I think you already found what the minikube docs say on avoiding password prompts and want something more granular than giving access to sudo ip.

/etc/sudoers can configure sudo quite granular, you can also allow password-less sudo for specific commands only:

username ALL=(ALL) NOPASSWD: /usr/bin/ip route add 10.96.0.0/12 via 192.168.64.194
  • the 10.96.0.0/12 is the cluster's service CIDR
    here the default and most likely also yours, otherwise check this SO.
  • the 192.168.64.194 is your minikube ip

I unfortunately cannot test this right now, but maybe it is you worth a try :)

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2022-09-09)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。