1
2
timedatectl set-timezone America/Los_Angeles
hostnamectl set-hostname ovwane.com
1
2
useradd 用户名
passwd 用户名
1
2
visudo
用户名 ALL=(ALL) ALL
1
ssh-keygen -t rsa -b 4096 -C "邮箱" -f linode_vps_rsa
1
2
3
4
5
mkdir ~/.ssh
vim ~/.ssh/authorized_keys

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

设置 SSH,打开密钥登录功能
编辑 /etc/ssh/sshd_config 文件,进行如下设置:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
vim /etc/ssh/sshd_config

Port 22
Protocol 2
RSAAuthentication yes
PubkeyAuthentication yes
#禁止root用户通过SSH登录
PermitRootLogin no
#禁用密码登录
PasswordAuthentication no
ChallengeResponseAuthentication no
GSSAPIAuthentication no
UsePAM yes
UseDNS no
X11Forwarding no

最后,重启 SSH 服务:
systemctl restart sshd.service

#优化

  1. 关闭SELinux

    1
    sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
  2. 最大进程数和最大文件打开数
    修改/etc/security/limits.conf文件

  3. 删除默认用户
    centos

  4. 更换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

EPEL mirrors

mirrors.cat.pdx.edu

yum upgrade](https://www.jianshu.com/p/4df7692bdc2b)

1
yum -y upgrade
1
2
3
4
rpm -qa | grep kernel  

yum -y autoremove kernel-3.10.0-693.el7
yum -y autoremove kernel-3.10.0-693.2.2.el7.x86_64
  1. 时间

    chrony

chrony软件使用说明

1
2
3
4
5
6
7
8
yum -y install chrony

systemctl start chronyd.service
systemctl enable chronyd.service
systemctl status chronyd.service

查看同步状态
chronyc sourcestats

删除软件包并删除孤立的依赖包
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

删除 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

centOS7服务管理与启动流程

下载必要软件包
再安装操作系统的时候使用的最小化安装,有很多包没有安装,使用时发现好多命令没有如{vim、wget、tree…等},下面就安装命令,可以根据需求自行调整。

1
2
yum -y install wget vim lrzsz screen lsof tree unzip git
# tcpdump nc mtr openssl-devel bash-completion nmap telnet ntpdate net-tools

开启firewalld

1
2
systemctl start firewalld.service
systemctl status firewalld.service

×

纯属好玩

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

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

文章目录
,