在安装完新系统后,往往需要做系统初始化,配置或修改一些必要配置
# 关闭
sudo ufw disable
# 禁用服务
sudo systemctl stop ufw && sudo systemctl disable ufw
# 配置NTP同步地址为`ntp.aliyun.com`
sudo vim /etc/systemd/timesyncd.conf
# [Time]
# NTP=ntp.aliyun.com
sudo timedatectl set-timezone Asia/Shanghai
sudo timedatectl set-ntp off
sudo timedatectl set-ntp on
sudo systemctl daemon-reload
sudo systemctl restart systemd-timesyncd
sudo sed -i 's/^GSSAPIAuthentication yes$/GSSAPIAuthentication no/' /etc/ssh/sshd_config
sudo sed -i 's/#UseDNS yes/UseDNS no/' /etc/ssh/sshd_config
sudo systemctl restart sshd.service
# 备份
sudo cp /etc/apt/sources.list /etc/apt/sources.list.backup
# 使用腾讯源,不同源文件可参考 http://mirrors.cloud.tencent.com/repo/
sudo wget -O /etc/apt/sources.list http://mirrors.cloud.tencent.com/repo/ubuntu20_sources.list
# 更新
sudo apt-get clean all
sudo apt-get update
sudo apt-get install -y htop net-tools openssl
sudo vi /etc/ssh/sshd_config
修改#Port 22
行为Port 指定端口
,保存后sudo systemctl restart sshd
或重启机器即可
sudo reboot
# 1. 设置root账号密码
sudo passwd root
# 2. 开启ssh允许root账号使用密码登录
sudo vim /etc/ssh/sshd_config
# 将# PermitRootLogin prohibit-password行 改为 PermitRootLogin yes
PermitRootLogin yes
修改完重启ssh服务或重启机器即可。不使用root
账号有利于安全,但是执行高权限命令时需要前边带sudo
,请根据实际情况开启