NO.A.0019——ubuntu20.04.1配置固定IP地址/开启root权限/开启ssh服务/

一、Ubuntu启动root用户权限,并使用root登录xshell远程工具

//Ubuntu20.04.1安装完成之后默认是没有root用户登录权限:
//1、使用普通用户登录,创建root用户的密码
yanqi@ubuntu:~$ sudo passwd
[sudo] password for yanqi:
New password:
Retype new password:
passwd: password updated successfully

//2、修改/usr/share/lightdm/lightdm.conf.d/50-ubuntu.conf配置文件
yanqi@ubuntu:~$ ll /usr/share/lightdm/lightdm.conf.d/50-ubuntu.conf
-rw-r--r-- 1 root root 29 3月  26  2020 /usr/share/lightdm/lightdm.conf.d/50-ubuntu.conf
yanqi@ubuntu:~$ sudo chmod 666 /usr/share/lightdm/lightdm.conf.d/50-ubuntu.conf
yanqi@ubuntu:~$ ll /usr/share/lightdm/lightdm.conf.d/50-ubuntu.conf
-rw-rw-rw- 1 root root 29 3月  26  2020 /usr/share/lightdm/lightdm.conf.d/50-ubuntu.conf
yanqi@ubuntu:~$ sudo vim /usr/share/lightdm/lightdm.conf.d/50-ubuntu.conf
greeter-show-manual-login=true
all-guest=false

//3、修改/etc/pam.d/gdm-autologin配置文件:
yanqi@ubuntu:~$ ll /etc/pam.d/gdm-autologin
-rw-r--r-- 1 root root 1192 10月  8  2019 /etc/pam.d/gdm-autologin
yanqi@ubuntu:~$ sudo chmod 666 /etc/pam.d/gdm-autologin
yanqi@ubuntu:~$ ll /etc/pam.d/gdm-autologin
-rw-rw-rw- 1 root root 1192 10月  8  2019 /etc/pam.d/gdm-autologin
yanqi@ubuntu:~$  sudo vim /etc/pam.d/gdm-autologin
#auth required pam_succeed_if.so user != root quiet_success             //注释掉第三行

//4、修改/etc/pam.d/gdm-password配置文件:
yanqi@ubuntu:~$ ll /etc/pam.d/gdm-password
-rw-r--r-- 1 root root 1320 10月  8  2019 /etc/pam.d/gdm-password
yanqi@ubuntu:~$ sudo chmod 666 /etc/pam.d/gdm-password
yanqi@ubuntu:~$ ll /etc/pam.d/gdm-password
-rw-rw-rw- 1 root root 1320 10月  8  2019 /etc/pam.d/gdm-password
yanqi@ubuntu:~$ sudo vim /etc/pam.d/gdm-password
#auth required pam_succeed_if.so user != root quiet_success             //注释掉第三行的

//5、修改/root/.profile配置文件
yanqi@ubuntu:~$ su root
root@ubuntu:~# ll /root/.profile
-rw-r--r-- 1 root root 161 12月  5  2019 /root/.profile
root@ubuntu:~# chmod 666 /root/.profile
root@ubuntu:~# ll /root/.profile
-rw-rw-rw- 1 root root 161 12月  5  2019 /root/.profile
root@ubuntu:~# vim /root/.profile
# mesg n 2> /dev/null || true           //注释掉这一行
tty -s&&mesg n || true                  //添加tty开启状态

二、Ubuntu配置虚拟机静态固定ip地址:

root@ubuntu:~# vim /etc/netplan/01-network-manager-all.yaml
  ethernets:
          ens33:
                  dhcp4: false
                  addresses: [192.168.1.92/24]
                  gateway4: 192.168.1.1
                  nameservers:
                          addresses: [114.114.114.114,8.8.8.8]

root@ubuntu:~# netplan apply

三、Ubuntu开启ssh服务,并通过xshell远程连接:

root@ubuntu:~# apt-get install openssh-server openssh-client
root@ubuntu:~# chmod 666 /etc/ssh/sshd_config
root@ubuntu:~# vim /etc/ssh/sshd_config
# Authentication:
#LoginGraceTime 2m
#PermitRootLogin prohibit-password
PermitRootLogin yes
StrictModes yes
root@ubuntu:~# systemctl restart ssh

四、更改Ubuntu下载原地址为国内源

root@ubuntu:~# chmod 666 /etc/apt/sources.list
root@ubuntu:~# vim /etc/apt/sources.list            //编辑配置文件,更换为国内源地址  //使用清华源地址
root@ubuntu:~# apt-get update && apt-get upgrade    //可以保证系统的完整性(upgrade更新,若依赖关系无法解决可能会报错或停止)                   
root@ubuntu:~# apt-get dist-upgrade                 //该命令也是更新所有软件包(慎用:自动解决依赖关系,可能更新一些不需要更新的包,导致一些需要依赖就报的程序无法运行)。
root@ubuntu:~# apt-get clean        

国内常用源地址:

# 阿里云源地址
deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse

# 清华源地址
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ eoan main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ eoan main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ eoan-updates main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ eoan-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ eoan-backports main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ eoan-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ eoan-security main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ eoan-security main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ eoan-proposed main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ eoan-proposed main restricted universe multiverse

猜你喜欢

转载自blog.51cto.com/15005403/2563681