启用root权限
# 设置密码
sudo passwd root
开通设置 SSH 连接方式
- 更新软件包列表
sudo apt update
- 安装 OpenSSH 服务端
sudo apt install openssh-server
- 启动 SSH 服务
sudo systemctl start ssh
- 设置 SSH 开机自启
sudo systemctl enable ssh
- 检查 SSH 服务状态
sudo systemctl status ssh
注: 确认输出显示 Active: active (running) 表示服务已正常运行。
- 配置防火墙(若启用 UFW)
# 允许 SSH 默认端口(22)
sudo ufw allow ssh
# 查看防火墙状态
sudo ufw status
- 配置 SSH 安全参数
sudo vim /etc/ssh/sshd_config
将"PermitRootLogin"后半段改为yes,删除前面的#号,保存退出
# 修改后需重启 SSH 服务
sudo systemctl restart ssh
查看网卡
查看ip命令
ifconfig
如果没安装需要安装net-tools, 安装命令
apt-get install net-tools