直接編輯/etc/sudoer提示文件只讀
查看該文件權限,發現是440,於是降低該文件權限。
#查看文件權限
[root@master sunny-test]# ls -l /etc/sudoers
-r--r-----. 1 root root 3938 Apr 11 2018 /etc/sudoers
#添加寫權限
[root@master sunny-test]# chmod u+w /etc/sudoers
[root@master sunny-test]# ls -l /etc/sudoers
-rw-r-----. 1 root root 3938 Apr 11 2018 /etc/sudoers
在此處加入sudo免密
修改後,再將文件權限變爲440
chmod 440 /etc/sudoers
#修改sudoers文件前,使用sudo命令需要輸入密碼
[ttop.sit@master ~]$ sudo ls
We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:
#1) Respect the privacy of others.
#2) Think before you type.
#3) With great power comes great responsibility.
[sudo] password for ttop.sit:
。。。省略。。。
#修改sudoers文件後,使用sudo命令不再需要密碼
[ttop.sit@master ~]$ sudo ls
[ttop.sit@master ~]$ sudo docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
2647a6da08ee 6e4bffa46d70 "kube-controller-man…" 3 weeks ago Up 3 weeks k8s_kube-controller-manager_kube-controller-manager-master_kube-system_c3fad56eae1f09ad7319dfa87a1ba6c4_3
c4d289e1a83a ebac1ae204a2 "kube-scheduler --au…" 3 weeks ago Up 3 weeks