023. Ubuntu common personalized configuration

Root login settings##

Ubuntu closes the root account by default, and root login can be turned on or off according to the actual situation.

ubuntu@localhost:~$ sudo apt install openssh-server
ubuntu@localhost:~$ sudo passwd root
New password:【enter password】
Retype newpassword:【enter password】
ubuntu@localhost:~$ sudo vim /etc/ssh/sshd_config
……
Port 22                                             #SSH port
……
PermitRootLogin yes                                 #Allow root user to log in
# PermitRootLogin no                                 #Prohibit root user login
PasswordAuthentication yes                          #Allow password login
# PasswordAuthentication no                          #Prohibit password login, such as using public key login
……
ubuntu@localhost:~$ sudo systemctl restart sshd     #Restart the sshd service

Modify DNS

It is recommended to modify the dns to the address of the domestic mainstream dns service provider, such as Alibaba Cloud dns.

root@localhost:~# vi /etc/netplan/50-cloud-init.yaml
network:
 ethernets:
  eth0:
   addresses:-172.24.8.111/24
   dhcp4:false
   gateway4:172.24.8.2
   nameservers:
    addresses:-223.5.5.5                 #Modify DNS to Alibaba Cloud public dns
    search:[]
 version:2

Modify apt source##

It is recommended to modify the apt source to the address of the domestic mainstream apt provider, such as Alibaba Cloud apt source.

root@localhost:~# sudo vim /etc/apt/sources.list
deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb-src 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-backports main restricted universe multiverse

More reference: https://developer.aliyun.com/mirror/ubuntu

Update system##

root@localhost:~# apt-get update && apt-get upgrade -y && apt-get autoremove -y

Install common server software##

root@localhost:~# sudo apt-get-y install net-tools vim wget ntp bash-completion build-essential gcc openssh-client lvm2 make terminator git ssh lrzsz htop

The above are mainly server-related software, and the necessary components can be installed according to the actual situation.

Modify locale##

root@localhost:~# sudo vi /etc/default/locale
LANG="zh_CN.UTF-8"
LANGUAGE="zh_CN:zh"                 #Set to Chinese

LANG="en_US.UTF-8"  
LANGUAGE="en_US:en"                 #Need to be in English

Create new user and key-free configuration##

Create user###

root@localhost:~# adduser xianghy   #Fill in the relevant information to create a user

Login test###

[ root@client ~]# ssh [email protected]       #Client test login
[email protected]'s password:【enter password】

Key-free login###

[ root@client ~]# ssh-keygen -f ~/.ssh/xianghy_key -N ''                         #Client creates private key
[ root@client ~]# ssh-copy-id -i ~/.ssh/xianghy_key.pub [email protected]     #Upload the public key to the server

Client configuration login alias###

[ root@client ~]# vim ~/.ssh/config
Host xianghyhost                    #Host alias
 HostName 172.24.8.111           #Server IP
 Port 22                         #Server SSH port
 User xianghy                    #Server user name
 IdentityFile ~/.ssh/xianghy_key #Private key file path
[ root@client ~]# chmod 600~/.ssh/config

Key-free login test###

[ root@client ~]# ssh xianghyhost    #Use alias login test

Turn off the firewall##

root@localhost:~# systemctl stop ufw.service
root@localhost:~# systemctl disable ufw.service

Clock server configuration##

chrony service configuration###

Reference: "001.Chrony Time Server"

Recommended Posts

023. Ubuntu common personalized configuration
Ubuntu common commands
2018-06-14Ubuntu common commands
ubuntu 18.04 early configuration
Ubuntu nfs configuration
Ubuntu20.04 configuration notes
Ubuntu 14.04 configuration record
ubuntu configuration python, Red
Ubuntu16.04 common command notes
Ubuntu configuration development environment
Ubuntu 18.04 network card configuration
Ubuntu development environment configuration
Network configuration under Ubuntu
Basic configuration and common software installation after ubuntu 18.04 installation
Common exceptions and solutions for Ubuntu system installation and configuration
Ubuntu16.04 installation and simple configuration
Install common software on Ubuntu 16.04
ubuntu builds common development environment
Ubuntu16.04 install SVN and configuration
Ubuntu PostgreSQL installation and configuration
Ubuntu environment variables and ADB configuration
Ubuntu 20.04 best configuration guide for engineers
Ubuntu 20.04 best configuration guide for engineers
Ubuntu18 super detailed common software installation
Ubuntu16.04 configuration OpenCV3.4.2 and basic use
Ubuntu 19.1 installation and configuration Chinese environment
Configuration and beautification after Ubuntu installation (1)
Nginx installation and configuration load (ubuntu12.04)
Ubuntu common instructions and usage details
Ubuntu configuration source and installation software
Ubuntu 20.04 best configuration guide (required for newbies)
JDK environment variable configuration method under ubuntu
Ubuntu17.04 configuration method to replace domestic sources
Ubuntu install PHP and PHP Nginx configuration method
Ubuntu 18.04 LTS configuration network tutorial through Netplan
DLNA/UPnP Server installation and configuration under Ubuntu 12.04