歡迎訪問我的個(gè)人博客網(wǎng)站:http://www.yanmin99.com/
一、創(chuàng)建root權(quán)限用戶步驟
-
1、創(chuàng)建用戶yanmin
- A、adduser yanmin
//創(chuàng)建用戶 [root@iZrj98p4hhys0y9fdxmcy4Z ~]# adduser yanmin- B、設(shè)置用戶密碼
//輸入兩次密碼 [root@iZrj98p4hhys0y9fdxmcy4Z ~]# passwd yanmin Changing password for user yanmin. New password: Retype new password: passwd: all authentication tokens updated successfully -
2、賦予yanmin用戶root權(quán)限
- A、第一種方案:修改/etc/sudoers文件,找到下面一行,在root下面添加一行
# User privilege specification root ALL=(ALL:ALL) ALL yanmin ALL=(ALL:ALL) ALL - B、第二種方案:修改/etc/passwd文件,找到如下行,把用戶ID修改為0,如下:
yanmin:x:0:1000:yanmin,,,:/home/yanmin:/bin/bash
- A、第一種方案:修改/etc/sudoers文件,找到下面一行,在root下面添加一行
-
3、測(cè)試用戶yanmin登錄
ssh yanmin@xx.xx.xx.xx - 4、如果想免密碼登陸,請(qǐng)參考
二、禁用root登錄步驟
-
1、準(zhǔn)備工作
- 注意:禁用root登陸之前,一定要確認(rèn)其他用戶可以登錄,并且具備root權(quán)限
-
2、把/etc/ssh/sshd_config中(PermitRootLogin no)設(shè)置YES
PermitRootLogin yes修改為 PermitRootLogin no -
3、重啟SSH daemon服務(wù)
//centos /etc/init.d/sshd restart //ubuntu //如果ssh重啟沒有效果,就重啟系統(tǒng) /etc/init.d/ssh restart shutdown -r now -
4、嘗試遠(yuǎn)程登陸
yanmin:~ yanmin$ ssh root@gitlab root@gitlab's password: Permission denied, please try again.