解决 Ubuntu 不能远程连接

287 阅读1分钟
  1. 安装openssh-server

sudo apt install openssh-server

  1. 防火墙添加允许默认的远程连接端口规则

sudo ufw allow 22

  • 拒绝root帐户连接的解决方法
Ubuntu服务器默认的root账号是没有激活的,需要用初装的用户账号给root设置管理密码:
命令:
$ sudo passwd root //用sudu修改root账号
Password:**** // 输入密码
Enter new UNIX password: **** //提示输入新的root账号密码
Retype new UNIX password: **** //在输入一次确认密码


$ vim /etc/ssh/sshd_config

找到#PermitRootLogin prohibit-password在后面添加一行

PermitRootLogin yes


重启ssh服务:
$ /etc/init.d/ssh restart