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
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
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
root@localhost:~# apt-get update && apt-get upgrade -y && apt-get autoremove -y
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.
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
root@localhost:~# adduser xianghy #Fill in the relevant information to create a user
[ root@client ~]# ssh [email protected] #Client test login
[email protected]'s password:【enter password】
[ 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
[ 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
[ root@client ~]# ssh xianghyhost #Use alias login test
root@localhost:~# systemctl stop ufw.service
root@localhost:~# systemctl disable ufw.service
Reference: "001.Chrony Time Server"
Recommended Posts