- 安装openssh-server
sudo apt update
sudo apt install openssh-server
- 安装完成后,查看ssh是否开启
sudo systemctl status ssh
- 如果没启动就手动
/etc/init.d/ssh start
- 配置SSH
sudo vim /etc/ssh/sshd_config
- 将
Port 22
前面的注释去掉,然后将PermitRootLogin prohibit-password
修改为PermitRootLogin yes
- 重启ssh
sudo systemctl restart ssh
- 设置开机自启ssh
sudo systemctl enable ssh
- 如果出现无法连接的情况,尝试关闭防火墙
sudo ufw status