普通用户新增sudo权限&禁止root远程登录
2014-09-03 14:15
501 查看
创建新用户
修改/etc/sudoers配置
cookie用户测试权限
在cookie用户中远程登录到root用户
找到
重启sshd服务器
完成
[root@localhost ~]# useradd cookie设置cookie用户的密码
[root@localhost ~]# passwd cookie新增窗口登录cookie用户
Xshell:\> ssh cookie@192.168.X.XX权限测试
[root@localhost ~]# /etc/init.d/sshd restart Stopping sshd: [ OK ] Starting sshd: [ OK ]root用户重启成功
[cookie@localhost ~]$ /etc/init.d/sshd restart /etc/init.d/sshd: line 33: /etc/sysconfig/sshd: Permission denied rm: cannot remove `/var/run/sshd.pid': Permission denied [FAILED] Starting sshd: /etc/ssh/sshd_config: Permission denied [FAILED]
[cookie@localhost ~]$ sudo /etc/init.d/sshd restart cookie is not in the sudoers file. This incident will be reported.cookie用户无权限,重启失败
修改/etc/sudoers配置
[root@localhost ~]# visudo -f /etc/sudoers找到
## Allow root to run any commands anywhere root ALL=(ALL) ALL修改为:
## Allow root to run any commands anywhere root ALL=(ALL) ALL保存,退出
cookie ALL=(ALL) ALL
cookie用户测试权限
[cookie@localhost ~]$ sudo /etc/init.d/sshd restart 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 cookie: Stopping sshd: [ OK ] Starting sshd: [ OK ]重启成功
在cookie用户中远程登录到root用户
在root用户下修改/etc/ssh/sshd_config文件
[root@localhost ~]# vi /etc/ssh/sshd_config
找到
#LoginGraceTime 2m #PermitRootLogin yes #StrictModes yes #MaxAuthTries 6 #MaxSessions 10将PermitRootLogin yes 改为 PermitRootLogin no 并去掉前面的#
#LoginGraceTime 2m PermitRootLogin no #StrictModes yes #MaxAuthTries 6 #MaxSessions 10
重启sshd服务器
完成
相关文章推荐
- centos7 创建普通用户,添加sudo权限,禁止root远程登录和公钥登录脚本
- centos添加普通用户禁止root登录并添加sudo权限
- linux禁止root用户登录,并开启普通用户sudo权限
- 普通用户的sudo权限,禁止root用户登录
- 增加普通用户的sudo权限,禁止root用户登录
- mysql 禁止root用户远程登录,创建一个只读权限用户进行远程登录
- su命令、sudo临时赋予其他用户权限命令、限制root用户远程登录
- 修改ssh端口、禁止root用户远程登录设置sudo
- Linux禁止root帐号远程直接登录, 只允许用普通用户登录
- 禁止root远程登录centos(启用sudo)
- linux禁止root用户远程登录
- PAM禁止root用户登录,限制普通su切换
- Linux禁止普通用户使用su 切换到root 用户(并且禁止root ssh登录)
- Ubuntu禁止普通用户通过sudo -i 或 sudo -s进入root模式解决办法
- 禁止root通过SSH远程登录访问与限制某些用户远程登录
- 使用sudo来赋予普通用户root的权限
- Linux禁止root用户SSH远程登录
- 【转】centos禁止root用户远程登录
- CentOS/Linux 禁止root用户远程登录
- 使用sudo来赋予普通用户root的权限 推荐