NO.A.0019——ubuntu20.04.1配置固定IP地址/開啟root許可權/開啟ssh服務/配置國內源地址
阿新 • • 發佈:2020-12-14
一、Ubuntu啟動root使用者許可權,並使用root登入xshell遠端工具
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
二、Ubuntu配置虛擬機器靜態固定ip地址://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開啟ssh服務,並通過xshell遠端連線: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下載原地址為國內源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
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="">