ubuntu server 20.04LTS開啓root賬號登錄

因 20.04LTS 版本沒有/usr/share/lightdm/lightdm.conf.d/50-ubuntu.conf文件, 所以大部分baidu的結果都不適合

1. 給root賬戶設置密碼

在當前普通用戶界面下輸入命令:

sudo passwd root

然後按提示兩次輸入密碼即可.

2. 安裝ssh服務

系統會自帶openssh-client, 但是不一定帶了openssh-server. 安裝了服務端纔會在/etc/ssh下有sshd_config文件.

要先判斷是否安裝了ssh-server(服務):

ssh localhost

如果提示"ssh: connect to host localhost port 22: Connection refused"則表示未安裝.

安裝:

sudo apt-get install openssh-server

查看服務是否啓動:

ps -aux | grep sshd

3. 修改sshd配置

sudo vi /etc/ssh/sshd_config

i進入編輯模式,找到#PermitRootLogin prohibit-password,默認是註釋掉的。

直接在下面添加一行

PermitRootLogin yes

然後按esc,輸入:wq保存並退出。

4. 重啓sshd服務

sudo systemctl restart sshd

ok, now, you can use root as login account.

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章