在安装 Ubuntu Server 时无法启用 root 账户,只能创建一个非 root 账户。
在安装后如何启用 root 账户?
#重设root账户密码
sudo -i passwd root
#用root账户登录
su - root
#安装ssh服务
apt install ssh
systemctl enable ssh
#修改sshd配置,允许root用户用密码登录
nano /etc/ssh/sshd_config.d/sshd.conf
#允许root用户登录
PermitRootLogin yes
#允许使用密码登录
PasswordAuthentication yes
#可选,删除装系统时配置的用户及文件
deluser --remove-home <username>
#改中国时区
timedatectl set-timezone Asia/Shanghai
重启 ssh 服务生效