-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathsecurity.html
68 lines (68 loc) · 2.21 KB
/
security.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv=Content-Type content="text/html; charset=utf-8">
<meta http-equiv=pragma content=no-cache>
<link href="css/bootstrap.min.css" rel="stylesheet">
<link rel="shortcut icon" href="favicon.ico">
<link rel="bookmark" href="favicon.ico">
<title>Linux服务器安全配置手册</title>
</head>
<body style="margin:20px">
<p><a href="index.html">返回首页</a></p>
<h2 align=center>Linux服务器安全配置手册</h2>
<p>注:以CentOS7为例。</p>
<p><b>一、系统安全</b></p>
<p><b>1、系统和软件都升级到最新</b></p>
<pre>yum update -y</pre>
<p><b>2、删除无用的系统账号</b></p>
<pre>userdel games
userdel avahi-autoipd
userdel operator
userdel ftp
userdel saslauth
userdel postfix</pre>
<p><b>3、安装firewalld防火墙</b></p>
<pre>yum install firewalld -y
systemctl start firewalld
systemctl enable firewalld</pre>
<p><b>4、禁用bash历史记录</b></p>
<pre>vi /etc/profile</pre>
<p>将</p>
<pre>HISTSIZE=1000</pre>
<p>改为:</p>
<pre>HISTSIZE=0</pre>
<p>然后:</p>
<pre>rm ~/.bash_history
history -c</pre>
<p><b>5、安装fail2ban</b></p>
<pre>yum install fail2ban</pre>
<p><b>二、ssh安全配置</b></p>
<p><b>1、修改ssh端口号</b></p>
<pre>vi /etc/ssh/sshd_config</pre>
<p>将</p>
<pre>#Port 22</pre>
<p>前面的#去掉,将默认的22改为你想要的端口号,尽量大于10000,可以大幅度减少被扫描的可能。</p>
<p><b>2、ssh限制登录IP</b></p>
<pre>vi /etc/ssh/sshd_config</pre>
<p>将以下规则添加到文件末尾:</p>
<pre>allowusers root@myip1
allowusers root@myip2</pre>
<p><b>3、使用key登录,禁止账号密码登录、禁用root用户登录</b></p>
<pre>vi ~/.ssh/authorized_keys</pre>
<p>将用puttykegen生成的pubkey复制到此文件中,一行一个账号。</p>
<pre>vi /etc/ssh/sshd_config</pre>
<p>将</p>
<pre>#PasswordAuthentication yes</pre>
<p>中的#去掉,并改为:</p>
<pre>PasswordAuthentication no</pre>
<p>将</p>
<pre>#PermitRootLogin yes</pre>
<p>中的#去掉,并改为:</p>
<pre>PermitRootLogin no</pre>
<p></p>
<p><a href="index.html">返回首页</a></p>
<p align="center">© 2016-2025 清风的个人笔记</p>
</div>
</body>
</html>