Linux的默認管理員名即是root,只需要知道ROOT密碼即可直接登錄SSH,禁止Root從SSH直接登錄可以提高服務器安全性,經過以下操作后即可實作,
本文適用于CentOS、Debian等Linux系統,
新建用戶
[root@CentOS ~]# useradd test
配置密碼
#使用passwd命令即可給相應帳戶設定或修改密碼,
[root@CentOS ~]# passwd test
#根據圖示,設定或修改密碼需要填寫兩次,第二次為效驗密碼,輸入完畢后請回車確認,
Changing password for user test.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.
配置不允許root用戶直接登錄
修改相關檔案
vi /etc/ssh/sshd_config
禁止root登陸
查找 #PermitRootLogin yes” 默認為132行
將“#”去掉,末尾“Yes”改為“No”
并wq保存
重啟sshd服務
systemctl restart sshd
測驗連接
可以看到 直接使用root 連接服務器 ssh會直接拒絕
正常連接方式
使用ssh 連接 先登錄普通用戶
登錄普通用戶之后使用 su - 登錄root用戶即可
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/142915.html
標籤:Linux
上一篇:《趣談 Linux 作業系統》學習筆記(一):為什么要學 Linux 及學習路徑
下一篇:linux---基礎學習
