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





 

Walter Savage Landor:strove with none,for none was worth my strife.Nature I loved and, next to Nature, Art:I warm'd both hands before the fire of life.It sinks, and I am ready to depart
                                                                                                                                                   ——W.S.Landor

 

<wiz_marker id="wiz-painter-root" style="">

 

 



posted on   yanqi_vip  阅读(268)  评论(0编辑  收藏  举报

编辑推荐:
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· DeepSeek 开源周回顾「GitHub 热点速览」
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

导航

统计

点击右上角即可分享
微信分享提示