普通用户新增sudo权限&禁止root远程登录
来源:互联网 发布:知乎 我也曾想一了百了 编辑:程序博客网 时间:2024/05/16 19:05
创建新用户
[root@localhost ~]# useradd cookie设置cookie用户的密码
[root@localhost ~]# passwd cookie新增窗口登录cookie用户
Xshell:\> ssh cookie@192.168.X.XX权限测试
[root@localhost ~]# /etc/init.d/sshd restartStopping sshd: [ OK ]Starting sshd: [ OK ]root用户重启成功
[cookie@localhost ~]$ /etc/init.d/sshd restart/etc/init.d/sshd: line 33: /etc/sysconfig/sshd: Permission deniedrm: 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 restartcookie 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 anywhereroot ALL=(ALL) ALL修改为:
## Allow root to run any commands anywhereroot ALL=(ALL) ALLcookie ALL=(ALL) ALL保存,退出
cookie用户测试权限
[cookie@localhost ~]$ sudo /etc/init.d/sshd restartWe trust you have received the usual lecture from the local SystemAdministrator. 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 2mPermitRootLogin no#StrictModes yes#MaxAuthTries 6#MaxSessions 10
重启sshd服务器
完成
1 0
- 普通用户新增sudo权限&禁止root远程登录
- 增加普通用户的sudo权限,禁止root用户登录
- 普通用户的sudo权限,禁止root用户登录
- centos添加普通用户禁止root登录并添加sudo权限
- 禁止root远程登录
- 我的服务器开发之路-禁止root登录和普通用户获取root权限
- linux配置禁止密码登陆,普通用户赋予sudo权限
- 禁止root远程直接登录
- FREEBSD禁止root远程登录
- 禁止root用户远程登录
- aix 禁止root远程登录
- 禁止root用户远程登录
- linu禁止root远程登录
- 禁止root用户登录,只允许普通用户登录
- 使用sudo来赋予普通用户root的权限
- 授权普通用户 sudo -i 使其具有root的权限
- 赋予普通用户sudo权限
- Linux禁止普通用户使用su 切换到root 用户(并且禁止root ssh登录)
- ANDROID内存优化(大汇总——上)
- Linux rtc驱动模块分析
- JUnit4 详解
- 王延炯_海量数据处理的架构与实践
- 黑马程序员---正则表达式
- 普通用户新增sudo权限&禁止root远程登录
- Plug-in com.android.ide.eclipse.adt was unable to load class android
- 二维码框架ZBarSDK的使用和自定义二维码扫描界面方法
- androidmanifest.xml详解
- linux 网卡软中断的查看与设置负载均衡
- HDU 3874 Necklace 离线+树状数组
- jQuery(expression, [context]) , $(即jQuery)的参数问题
- 模拟share_ptr的实现-01-简单实现
- 通知栏点击PendintIntent没有反应