初始化配置ubuntu服务器(阿里云)
- 重置root密码并通过控制台admin用户连接
- 切换到root用户
su -
- 添加常用sudo用户
adduser [username] sudo usermod -aG sudo [username]
- 修改主机名
vim /etc/hostname #修改主机名 vim /etc/hosts #如必要才修改 hostnamectl set-hostname [hostname] #实时生效不固化 systemctl restart systemd-hostnamed
- 禁用root远程登录
vim /etc/ssh/sshd_config #set 'PermitRootLogin no' systemctl restart ssh
optional: ``` #sshd_config配置: Match User [username] PasswordAuthentication yes PubkeyAuthentication yes
```