配置主机名

1
hostnamectl set-hostname 域名

添加用户

1
useradd 用户名

添加 sudo 权限 Ubuntu 设置当前用户sudo免密码

1
visudo

root ALL=(ALL) ALL 下面一行,添加用户名 ALL=(ALL) NOPASSWD: ALL

生成 ssh key

1
ssh-keygen -o -a 100 -t ed25519 -C "邮箱" -f ~/.ssh/tencent_vps_ed

添加 ssh public key

1
2
3
4
5
6
7
su 用户名

mkdir ~/.ssh
vim ~/.ssh/authorized_keys

chmod 600 ~/.ssh/authorized_keys
chmod 700 ~/.ssh

配置 SSH

1
vim /etc/ssh/sshd_config
1
2
3
4
5
6
7
8
9
10
11
12
Port 22
Protocol 2
RSAAuthentication yes
PubkeyAuthentication yes
# 禁止 root 用户通过 SSH 登录
PermitRootLogin no
# 禁用密码登录
PasswordAuthentication no
ChallengeResponseAuthentication no
UsePAM yes
UseDNS no
X11Forwarding yes

重启 SSH 服务

1
systemctl restart sshd.service

删除 ntp

1
2
3
4
5
6
7
yum list installed |grep ntp

yum -y autoremove ntp

rm -rf /etc/ntp.conf.rpmsave

yum -y autoremove ntpdate

更新系统 yum upgrade

1
yum -y upgrade

删除老版本 kernel

1
2
3
4
5
6
# 查看 kernel
rpm -qa | grep kernel

# 重启后新 kernel 生效了,才能删除老版本的 kernel
yum -y autoremove kernel-3.10.0-862.el7
yum -y autoremove kernel-devel-3.10.0-862.el7

时间同步

chrony

chrony软件使用说明

1
2
3
4
5
6
7
8
9
10
# 安装
yum -y install chrony

# 启动
systemctl start chronyd.service
systemctl enable chronyd.service
systemctl status chronyd.service

# 查看同步状态
chronyc sourcestats

安装常用软件

1
2
3
4
5
# 工具
yum install -y lrzsz tmux wget vim git tree unzip

# 网络
yum install -y nc tcpdump mtr nmap telnet lsof net-tools sysstat

参考

centOS7服务管理与启动流程 - Linuxbugs - 博客园

#优化

  1. 关闭SELinux
  2. 关闭firewalld
  3. 最大进程数和最大文件打开数
    修改/etc/security/limits.conf文件
  4. 删除默认用户
    centos

  5. 更换yum源
    CentOS mirrors List

1
2
3
4
5
6
7
8
9
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo

删除缓存
yum clean all
rm -rf /var/cache/yum

生成缓存
yum makecache

删除软件包并删除孤立的依赖包
https://segmentfault.com/q/1010000000626683

1
2
3
4
需要在 /etc/yum.conf 里面添加一个配置:
clean_requirements_on_remove=1

yum autoremove

删除postfix

1
yum -y autoremove postfix
1
2
3
touch /var/lock/subsys/local
/usr/local/qcloud/rps/set_rps.sh >/tmp/setRps.log 2>&1
/usr/local/qcloud/irq/net_smp_affinity.sh >/tmp/net_affinity.log 2>&1

删除 firewalld

删除 wpa_supplicant

1
yum -y autoremove wpa_supplicant

删除用户

1
2
3
4
5
6
7
8
9
/etc/passwd
/etc/shadow
/etc/group
/etc/gshadow

postfix
ntp
games
ftp

×

纯属好玩

扫码支持
扫码打赏,你说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

文章目录
  1. 1. 参考
,