解决Ubuntu安装后不能远程连接的问题

在我们刚刚安装好Ubuntu后,想用xshell等其他软件远程连接的时候,发现连不上,原因有以下几点:

第一个原因:安装Ubuntu时没有选中安装openssh-server,解决方法如下:

1.安装openssh-server

sudo apt install -y openssh-server

2.开启ssh服务

sudo systemctl start sshd

3.修改/etc/ssh/sshd_config配置文件

sudo vim /etc/ssh/sshd_config

找到 PermitRootLogin 开头的行,将这行的注释删掉,然后将 PermitRootLogin 后面的东西改成yes,即最后的结果是 PermitRootLogin yes

4.重启ssh服务

sudo systemctl restart sshd

第二个原因:安装Ubuntu时已经选中安装openssh-server,但是无论是开启ssh服务或者是重启ssh服务,系统都会报错Job for ssh.service failed bacause......具体原因不清楚,可能是安装系统时有错误,解决方法如下:

1.卸载openssh-server

sudo apt purge -y openssh-server

2.安装openssh-server

sudo apt install -y openssh-server

3.开启ssh服务

sudo systemctl start sshd

接着步骤和上面一样了

你可能感兴趣的:(ubuntu,linux,运维)