root账号登录

1.默认使用ubuntu用户登录,密码为服务器配置时设置的密码,可在重置密码中修改

2.修改 root 密码

sudo passwd root

3.修改配置文件

sudo vi /etc/ssh/sshd_config

找到下面相关配置:

Authentication:
LoginGraceTime 120
PermitRootLogin prohibit-password
StrictModes yes

更改为:

Authentication:
LoginGraceTime 120
#PermitRootLogin prohibit-password
PermitRootLogin yes
StrictModes yes
PasswordAuthentication yes //默认为no,改为yes开启密码登陆`

4.重启ssh

sudo service ssh restart

接下来就可以putty使用root登录了


静态IP(ubuntu16.04)

1、vi /etc/network/interfaces

添加内容:

auto eth0
iface eth0 inet static
address 192.168.8.100    
netmask 255.255.255.0
gateway 192.168.8.2
dns-nameserver 119.29.29.29

dns-nameserver 119.29.29.29这句一定需要有,

因为以前是DHCP解析,所以会自动分配DNS 服务器地址。

而一旦设置为静态IP后就没有自动获取到DNS服务器了,需要自己设置一个

设置完重启电脑后,/etc/resolv.conf 文件中会自动添加 nameserver 119.29.29.29

(或者nameserver 8.8.8.8)可以根据访问速度,选择合适的公共DNS

2、重启网络:sudo /etc/init.d/networking restart

后来发现出现这个错误的原因,是因为Ubuntu16.04中的网卡名称不是eth0。

具体是网卡名称可以通过ifocnfig命令查看,我的机子的网卡名称为enp0s25,有些机子的网卡名称可能是ens33,将eth0改成自己的机子的网卡名称,然后保存推出,重启网络,发现成功了!大功告成。

ubuntu18.04看一下地址:https://www.cnblogs.com/yaohong/p/11593989.html

Last modification:March 29, 2020
如果觉得我的文章对你有用,请随意赞赏