-
Notifications
You must be signed in to change notification settings - Fork 0
/
20180913-3.html
701 lines (405 loc) · 39.3 KB
/
20180913-3.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<!-- 元数据 -->
<meta charset="utf-8">
<link rel="icon" href="/images/favicon.ico">
<title>常用的linux安全处理 | 云海鹰影</title>
<meta name="author" content="云海鹰影" />
<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="robots" content="index,follow" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
<meta name="format-detection" content="telphone=no, email=no" />
<meta name="keywords" content="linux基础, linux安全, 编程基础" />
<!-- 站点验证相关 -->
<meta name="baidu-site-verification" content="code-EjIoHOEm6V" />
<link rel="alternate" href="atom.xml" type="application/atom+xml">
<!-- 样式表文件 -->
<link rel="stylesheet" id="kratos-css" href="/css/kratosr.min.css" type="text/css" media="all">
<link rel="stylesheet" id="highlight-css" href="/css/highlight.min.css" type="text/css" media="all">
<link rel="stylesheet" id="fontawe-css" href="https://cdn.jsdelivr.net/npm/[email protected]/css/font-awesome.min.css" type="text/css" media="all">
<link rel="stylesheet" id="nprogress-css" href="https://cdn.jsdelivr.net/npm/[email protected]/nprogress.min.css" type="text/css" media="all">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/fancyapps/[email protected]/dist/jquery.fancybox.min.css">
<link rel="stylesheet" id="darkmode-css" href="/css/kr-dark.min.css" type="text/css" media="all">
<!-- 不得不预先加载的一些JS文件 -->
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/qrcode.min.js"></script>
<meta name="generator" content="Hexo 5.4.2"></head>
<body class="custom-background">
<div id="kratos-wrapper">
<div id="kratos-page">
<div id="kratos-header">
<div class="nav-toggle"><a class="kratos-nav-toggle js-kratos-nav-toggle"><i></i></a></div>
<header id="kratos-header-section">
<div class="container">
<div class="nav-header">
<div class="color-logo"><a href="/">云海鹰影</a></div>
<nav id="kratos-menu-wrap">
<ul id="kratos-primary-menu" class="sf-menu">
<li><a href="/" ><i class="fa fa-home"></i>首页</a></li>
<li><a href="/tags/" ><i class="fa fa-file"></i>标签云</a></li>
<li><a href="/archives/" ><i class="fa fa-file"></i>档案馆</a></li>
<li><a href="/friends/" ><i class="fa fa-paw"></i>友链</a></li>
<li>
<a ><i class="fa fa-umbrella"></i>秘密小窝</a>
<ul class="sub-menu">
<li><a target="_blank" rel="noopener" href="https://smp.chaoswork.cn" >鹰の巢</a></li>
</ul>
</li>
<li>
<a ><i class="fa fa-random"></i>资源库</a>
<ul class="sub-menu">
<li><a href="/resources/frontend" >前端</a></li>
<li><a href="/resources/backend" >后端</a></li>
<li><a href="/resources/tools" >工具</a></li>
</ul>
</li>
<li>
<a ><i class="fa fa-gift"></i>看动漫</a>
<ul class="sub-menu">
<li><a target="_blank" rel="noopener" href="https://www.5dm.tv/" >五弹幕</a></li>
</ul>
</li>
</ul>
</nav>
</div>
</div>
</header>
</div>
<div class="kratos-start kratos-hero-2">
<!-- <div class="kratos-overlay"></div> -->
<div class="kratos-cover kratos-cover-2 text-center">
<div class="desc desc2 animate-box">
<a href="/">
<h2>云海鹰影</h2> <br />
<span>我独自度过的无数个晨昏,用来交换你身边一瞬</span>
</a>
</div>
</div>
</div>
<div id="kratos-blog-post">
<div class="container">
<div class="row">
<div id="main">
<section class="col-md-8">
<article>
<div class="kratos-hentry kratos-post-inner clearfix">
<header class="kratos-entry-header">
<h1 class="kratos-entry-title text-center">常用的linux安全处理</h1>
<div class="kratos-post-meta text-center">
<span>
<i class="fa fa-calendar"></i> 2018-09-13
<i class="fa fa-folder"></i> 分类 <a class="label-link" href="/categories/%E7%BC%96%E7%A8%8B%E5%9F%BA%E7%A1%80/">编程基础</a>, <a class="label-link" href="/categories/%E7%BC%96%E7%A8%8B%E5%9F%BA%E7%A1%80/linux%E5%9F%BA%E7%A1%80/">linux基础</a>
<i class="fa fa-user"></i> 作者 云海鹰影
<i class="fa fa-edit"></i>
~2.60K
字
</span>
</div>
</header>
<div class="kratos-post-content">
<div id="expire-alert" class="alert alert-warning hidden" role="alert">
本文最后编辑于 <time datetime="1615457057379"></time> 前,其中的内容可能需要更新。
</div>
<hr />
<h2 id="一、登录安全"><a href="#一、登录安全" class="headerlink" title="一、登录安全"></a>一、登录安全</h2><h3 id="1-1-修改ssh端口"><a href="#1-1-修改ssh端口" class="headerlink" title="1.1 修改ssh端口"></a>1.1 修改ssh端口</h3><p>修改SSH默认端口,可以降低各种暴力攻击的风险。<br>SSH端口默认为22,编辑<code>/etc/ssh/sshd_config</code>, 修改Port,然后重启sshd服务。</p>
<figure class="highlight plaintext" data-lang="plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"># Port 22</span><br><span class="line">Port 12345</span><br></pre></td></tr></table></figure>
<h3 id="1-2-设置最大登录尝试次数"><a href="#1-2-设置最大登录尝试次数" class="headerlink" title="1.2 设置最大登录尝试次数"></a>1.2 设置最大登录尝试次数</h3><p>设置较低的最大登录场是次数,可以降低SSH服务器被暴力攻击成功的风险。<br>编辑<code>/etc/ssh/sshd_config</code>,取消MaxAuthTries注释符号#,设置最大密码尝试失败次数3-6,建议为4:</p>
<figure class="highlight plaintext" data-lang="plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">MaxAuthTries 4</span><br></pre></td></tr></table></figure>
<h3 id="1-3-SSHD强制使用V2安全协议"><a href="#1-3-SSHD强制使用V2安全协议" class="headerlink" title="1.3 SSHD强制使用V2安全协议"></a>1.3 SSHD强制使用V2安全协议</h3><p>编辑<code>/etc/ssh/sshd_config</code>,文件以按如下方式设置参数:</p>
<figure class="highlight plaintext" data-lang="plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">Protocol 2</span><br></pre></td></tr></table></figure>
<h3 id="1-4-设置SSH空闲超时退出时间"><a href="#1-4-设置SSH空闲超时退出时间" class="headerlink" title="1.4 设置SSH空闲超时退出时间"></a>1.4 设置SSH空闲超时退出时间</h3><p>设置SSH空闲超时退出时间,可降低未授权用户访问其他用户ssh会话的风险。<br>编辑<code>/etc/ssh/sshd_config</code>,将ClientAliveInterval 设置为300到900,即5-15分钟,将ClientAliveCountMax设置为0-3。</p>
<figure class="highlight plaintext" data-lang="plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">ClientAliveInterval 600</span><br><span class="line">ClientAliveCountMax 2</span><br></pre></td></tr></table></figure>
<h3 id="1-5-确保SSH-LogLevel设置为INFO"><a href="#1-5-确保SSH-LogLevel设置为INFO" class="headerlink" title="1.5 确保SSH LogLevel设置为INFO"></a>1.5 确保SSH LogLevel设置为INFO</h3><p>确保SSH LogLevel设置为INFO,记录登录和注销活动。<br>编辑<code>/etc/ssh/sshd_config</code>,取消LogLevel注释符号#,将其设置为INFO:</p>
<figure class="highlight plaintext" data-lang="plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">LogLevel INFO</span><br></pre></td></tr></table></figure>
<h3 id="1-6-禁用root登录"><a href="#1-6-禁用root登录" class="headerlink" title="1.6 禁用root登录"></a>1.6 禁用root登录</h3><p>root用户权限太高,不小心可能引起误操作。可以禁用root登录,以拥有sudo权限的用户登录。</p>
<h4 id="1-6-1-创建sudo用户"><a href="#1-6-1-创建sudo用户" class="headerlink" title="1.6.1 创建sudo用户:"></a>1.6.1 创建sudo用户:</h4><figure class="highlight sh" data-lang="sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">useradd username</span><br><span class="line">passwd username </span><br><span class="line">visudo <span class="comment"># 去掉%wheel ALL=(ALL) ALL前的#</span></span><br><span class="line">usermod -aG wheel username</span><br></pre></td></tr></table></figure>
<h4 id="1-6-2-禁用root登录:"><a href="#1-6-2-禁用root登录:" class="headerlink" title="1.6.2 禁用root登录:"></a>1.6.2 禁用root登录:</h4><p>编辑<code>/etc/ssh/sshd_config</code>,将PermitRootLogin配置为no:</p>
<figure class="highlight plaintext" data-lang="plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">PermitRootLogin no</span><br></pre></td></tr></table></figure>
<h3 id="1-7-采用密钥对登录,禁用密码登录"><a href="#1-7-采用密钥对登录,禁用密码登录" class="headerlink" title="1.7 采用密钥对登录,禁用密码登录"></a>1.7 采用密钥对登录,禁用密码登录</h3><h4 id="1-7-1-设置sshkey登录"><a href="#1-7-1-设置sshkey登录" class="headerlink" title="1.7.1 设置sshkey登录:"></a>1.7.1 设置sshkey登录:</h4><p>在客户端本地创建sshkey,将公钥id_rsa.pub内容拷贝到远程服务器用户目录下~/.ssh/authorized_keys文件中。</p>
<figure class="highlight sh" data-lang="sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#客户端本地操作</span></span><br><span class="line">ssh-keygen -t rsa</span><br><span class="line">scp ~/.ssh/id_rsa.pub [user]@[serverhost]:[port]/home/[user]/client_id_rsa.pub</span><br><span class="line"><span class="comment">#用[user]账号登录远程服务器,执行以下命令:</span></span><br><span class="line"><span class="built_in">cat</span> ~/client_id_rsa.pub >> ~/.ssh/authorized_keys</span><br></pre></td></tr></table></figure>
<h4 id="1-7-2-禁用密码登录"><a href="#1-7-2-禁用密码登录" class="headerlink" title="1.7.2 禁用密码登录:"></a>1.7.2 禁用密码登录:</h4><p>编辑<code>/etc/ssh/sshd_config</code>,将PasswordAuthentication配置为no:</p>
<figure class="highlight plaintext" data-lang="plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">PasswordAuthentication no</span><br></pre></td></tr></table></figure>
<h2 id="二、密码安全"><a href="#二、密码安全" class="headerlink" title="二、密码安全"></a>二、密码安全</h2><h3 id="2-1-禁用空密码登录"><a href="#2-1-禁用空密码登录" class="headerlink" title="2.1 禁用空密码登录"></a>2.1 禁用空密码登录</h3><p>编辑<code>/etc/ssh/sshd_config</code>,将PermitEmptyPasswords配置为no:</p>
<figure class="highlight plaintext" data-lang="plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">PermitEmptyPasswords no</span><br></pre></td></tr></table></figure>
<h3 id="2-2-密码复杂度检查"><a href="#2-2-密码复杂度检查" class="headerlink" title="2.2 密码复杂度检查"></a>2.2 密码复杂度检查</h3><p>使用非密码登陆方式如密钥对,请忽略此项。<br>编辑<code>/etc/security/pwquality.conf</code>,把minlen(密码最小长度)设置为9-32位,把minclass设置为3或4。如:</p>
<figure class="highlight plaintext" data-lang="plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">minlen=10</span><br><span class="line">minclass=3</span><br></pre></td></tr></table></figure>
<p>【minlen=密码最小长度,minclass=密码至少包含小写字母、大写字母、数字、特殊字符等4类字符中的种类数)】</p>
<h3 id="2-3-设置密码失效时间"><a href="#2-3-设置密码失效时间" class="headerlink" title="2.3 设置密码失效时间"></a>2.3 设置密码失效时间</h3><p>使用非密码登陆方式如密钥对,请忽略此项。<br>编辑<code>/etc/login.defs</code>,将 PASS_MAX_DAYS 参数设置为 60-180之间,如:</p>
<figure class="highlight plaintext" data-lang="plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">PASS_MAX_DAYS 90</span><br></pre></td></tr></table></figure>
<p>同时执行命令使root用户设置生效:</p>
<figure class="highlight sh" data-lang="sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">chage --maxdays 90 root</span><br></pre></td></tr></table></figure>
<h3 id="2-4-设置密码修改最小间隔时间"><a href="#2-4-设置密码修改最小间隔时间" class="headerlink" title="2.4 设置密码修改最小间隔时间"></a>2.4 设置密码修改最小间隔时间</h3><p>使用非密码登陆方式如密钥对,请忽略此项。<br>编辑<code>/etc/login.defs</code>,将 PASS_MIN_DAYS 参数设置为7-14之间,建议为7:<br> <figure class="highlight plaintext" data-lang="plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">PASS_MIN_DAYS 7</span><br></pre></td></tr></table></figure><br>同时执行命令使root用户设置生效:</p>
<figure class="highlight sh" data-lang="sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">chage --mindays 7 root</span><br></pre></td></tr></table></figure>
<h3 id="2-5-确保密码到期警告天数为7或更多"><a href="#2-5-确保密码到期警告天数为7或更多" class="headerlink" title="2.5 确保密码到期警告天数为7或更多"></a>2.5 确保密码到期警告天数为7或更多</h3><p>使用非密码登陆方式如密钥对,请忽略此项。<br>编辑<code>/etc/login.defs</code>,将 PASS_WARN_AGE 参数设置为7-14之间,建议为7:</p>
<figure class="highlight plaintext" data-lang="plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">PASS_WARN_AGE 7</span><br></pre></td></tr></table></figure>
<p>同时执行命令使root用户设置生效: </p>
<figure class="highlight plaintext" data-lang="plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">chage --warndays 7 root</span><br></pre></td></tr></table></figure>
<h2 id="三、系统权限管理"><a href="#三、系统权限管理" class="headerlink" title="三、系统权限管理"></a>三、系统权限管理</h2><h3 id="3-1-设置用户权限配置文件的权限"><a href="#3-1-设置用户权限配置文件的权限" class="headerlink" title="3.1 设置用户权限配置文件的权限"></a>3.1 设置用户权限配置文件的权限</h3><p>建议执行以下5条命令:</p>
<figure class="highlight plaintext" data-lang="plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">chown root:root /etc/passwd /etc/shadow /etc/group /etc/gshadow</span><br><span class="line">chmod 0644 /etc/group</span><br><span class="line">chmod 0644 /etc/passwd</span><br><span class="line">chmod 0400 /etc/shadow</span><br><span class="line">chmod 0400 /etc/gshadow</span><br></pre></td></tr></table></figure>
<h2 id="四、配置安全组策略"><a href="#四、配置安全组策略" class="headerlink" title="四、配置安全组策略"></a>四、配置安全组策略</h2><ol>
<li>待整理。</li>
</ol>
<h2 id="五、服务和辅助工具"><a href="#五、服务和辅助工具" class="headerlink" title="五、服务和辅助工具"></a>五、服务和辅助工具</h2><ol>
<li>禁用不需要的服务:<figure class="highlight sh" data-lang="sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">systemctl <span class="built_in">disable</span> service_name</span><br></pre></td></tr></table></figure></li>
<li>安装fail2ban, 监控服务器攻击。</li>
</ol>
<h2 id="六、应用服务安全"><a href="#六、应用服务安全" class="headerlink" title="六、应用服务安全"></a>六、应用服务安全</h2><h3 id="6-1-mysql安全"><a href="#6-1-mysql安全" class="headerlink" title="6.1 mysql安全"></a>6.1 mysql安全</h3><ol>
<li>修改mysql端口:mysql默认端口为3306,编辑<code>/etc/my.cnf</code> (查看自己mysql配置文件位置), 找到端口修改,然后重启mysqld服务。</li>
</ol>
<h3 id="6-2-redis安全"><a href="#6-2-redis安全" class="headerlink" title="6.2 redis安全"></a>6.2 redis安全</h3><ol>
<li><p>修改redis端口:redis默认端口6379,默认绑定127.0.0.1,编辑<code>/etc/redis.conf</code>(查看自己redis配置文件位置),修改端口后重启服务。</p>
<h2 id="七、做好服务器运维"><a href="#七、做好服务器运维" class="headerlink" title="七、做好服务器运维"></a>七、做好服务器运维</h2></li>
<li><p>检查服务器运行的服务和开启的端口</p>
<figure class="highlight sh" data-lang="sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">netstat -npl</span><br><span class="line">systemctl list-unit-files --<span class="built_in">type</span>=service | grep enabled</span><br></pre></td></tr></table></figure></li>
<li><p>其他待整理。</p>
</li>
</ol>
</div>
<div class="kratos-copyright text-center clearfix">
<h5>本作品采用 <a rel="license nofollow" target="_blank" href="http://creativecommons.org/licenses/by-sa/4.0/">知识共享署名-相同方式共享 4.0 国际许可协议</a> 进行许可</h5>
</div>
<footer class="kratos-entry-footer clearfix">
<div class="post-like-donate text-center clearfix" id="post-like-donate">
<a class="share" href="javascript:;"><i class="fa fa-share-alt"></i> 分享</a>
<div class="share-wrap" style="display: none;">
<div class="share-group">
<a href="javascript:;" class="share-plain qq" onclick="share('qq');" rel="nofollow">
<div class="icon-wrap">
<i class="fa fa-qq"></i>
</div>
</a>
<a href="javascript:;" class="share-plain qzone" onclick="share('qzone');" rel="nofollow">
<div class="icon-wrap">
<i class="fa fa-star"></i>
</div>
</a>
<a href="javascript:;" class="share-plain weixin pop style-plain" rel="nofollow">
<div class="icon-wrap">
<i class="fa fa-weixin"></i>
</div>
<div class="share-int">
<div class="qrcode" id="wechat-qr"></div>
<p>打开微信“扫一扫”,打开网页后点击屏幕右上角分享按钮</p>
</div>
</a>
<a href="javascript:;" class="share-plain weibo" onclick="share('weibo');" rel="nofollow">
<div class="icon-wrap">
<i class="fa fa-weibo"></i>
</div>
</a>
<a href="javascript:;" class="share-plain facebook style-plain" onclick="share('facebook');" rel="nofollow">
<div class="icon-wrap">
<i class="fa fa-facebook"></i>
</div>
</a>
<a href="javascript:;" class="share-plain twitter style-plain" onclick="share('twitter');" rel="nofollow">
<div class="icon-wrap">
<i class="fa fa-twitter"></i>
</div>
</a>
</div>
<script type="text/javascript">
$(()=>{
new QRCode("wechat-qr", {
text: "https://www.chaoswork.cn/20180913-3.html",
width: 150,
height: 150,
correctLevel : QRCode.CorrectLevel.H
});
});
function share(dest) {
const qqBase = "https://connect.qq.com/widget/shareqq/index.html?";
const weiboBase = "https://service.weibo.com/share/share.php?";
const qzoneBase = "https://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?";
const facebookBase = "https://www.facebook.com/sharer/sharer.php?";
const twitterBase = "https://twitter.com/intent/tweet?";
const hostUrl = "https://www.chaoswork.cn/20180913-3.html";
const title = "「常用的linux安全处理」";
const excerpt = `一、登录安全1.1 修改ssh端口修改SSH默认端口,可以降低各种暴力攻击的风险。SSH端口默认为22,编辑/etc/ssh/sshd_config, 修改Port,然后重启sshd服务。
12# Port 22Port 12345
...`;
let _URL;
switch (dest) {
case "qq" : _URL = qqBase+"url="+hostUrl+"&title="+title+"&desc=&summary="+excerpt+"&site=cxpy"; break;
case "weibo" : _URL = weiboBase+"url="+hostUrl+"&title="+title+excerpt; break;
case "qzone" : _URL = qzoneBase+"url="+hostUrl+"&title="+title+"&desc=&summary="+excerpt+"&site=cxpy"; break;
case "facebook" : _URL = facebookBase+"u="+hostUrl; break;
case "twitter" : _URL = twitterBase+"text="+title+excerpt+"&url="+hostUrl; break;
}
window.open(_URL);
};
</script>
</div>
</div>
<div class="footer-tag clearfix">
<div class="pull-left">
<i class="fa fa-tags"></i>
<a class="tag-none-link" href="/tags/linux%E5%9F%BA%E7%A1%80/" rel="tag">linux基础</a>, <a class="tag-none-link" href="/tags/linux%E5%AE%89%E5%85%A8/" rel="tag">linux安全</a>, <a class="tag-none-link" href="/tags/%E7%BC%96%E7%A8%8B%E5%9F%BA%E7%A1%80/" rel="tag">编程基础</a>
</div>
<div class="pull-date">
<span>最后编辑:2021-03-11</span>
</div>
</div>
</footer>
</div>
<nav class="navigation post-navigation clearfix" role="navigation">
<div class="nav-previous clearfix">
<a title=" 软件质量模型的六大特性" href="/20180913-2.html">< 上一篇</a>
</div>
<div class="nav-next clearfix">
<a title=" 【转】搞ACM的你伤不起" href="/20180913-4.html">下一篇 ></a>
</div>
</nav>
<link rel="stylesheet" href="https://cdn.bootcss.com/gitalk/1.4.1/gitalk.min.css">
<div id="gitalk-container"></div>
<script type="text/javascript">
var load_comm = () => {
const init = () => {
const gitalk = new Gitalk({
// Gitalk配置
language: "zh-CN",
clientID: "7dff06239ac01f6006c8",
clientSecret: "1cf779fc33e9e0d353f196eefa4bb43ecd560889",
repo: "comment_data",
owner: "stayknight",
admin: ["stayknight"],
id: location.pathname,
distractionFreeMode: false
});
gitalk.render('gitalk-container');
};
if (typeof Gitalk == 'undefined') {
const src = 'https://cdn.bootcss.com/gitalk/1.4.1/gitalk.min.js';
$.getScript(src, init);
} else {
init();
}
};
</script>
</article>
</section>
</div>
<section id="kratos-widget-area" class="col-md-4 hidden-xs hidden-sm">
<aside id="krw-about" class="widget widget-kratos-about clearfix">
<div class="photo-background"></div>
<div class="photo-wrapper clearfix">
<div class="photo-wrapper-tip text-center">
<img class="about-photo" src="https://cdn.jsdelivr.net/npm/[email protected]/avatars/icon41.jpg" />
</div>
</div>
<div class="textwidget">
<p class="text-center">路漫漫其修远兮,吾将上下而求索~<br/><span>(右下角搜索)</span></p>
</div>
</aside>
<!-- Moved to about.ejs -->
<aside id="krw-categories" class="widget widget-categories clearfix">
<h4 class="widget-title"><i class="fa fa-folder"></i>分类目录</h4>
<ul class="category-list"><li class="category-list-item"><a class="category-list-link" href="/categories/ACGN/">ACGN</a><span class="category-list-count">5</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/%E5%89%8D%E7%AB%AF%E5%BC%80%E5%8F%91/">前端开发</a><span class="category-list-count">1</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/%E6%B8%B8%E6%88%8F%E5%BC%80%E5%8F%91/">游戏开发</a><span class="category-list-count">1</span><ul class="category-list-child"><li class="category-list-item"><a class="category-list-link" href="/categories/%E6%B8%B8%E6%88%8F%E5%BC%80%E5%8F%91/%E6%9C%8D%E5%8A%A1%E5%99%A8/">服务器</a><span class="category-list-count">1</span></li></ul></li><li class="category-list-item"><a class="category-list-link" href="/categories/%E7%94%9F%E6%B4%BB%E5%AD%A6%E4%B9%A0/">生活学习</a><span class="category-list-count">8</span><ul class="category-list-child"><li class="category-list-item"><a class="category-list-link" href="/categories/%E7%94%9F%E6%B4%BB%E5%AD%A6%E4%B9%A0/%E6%9D%82%E8%B0%88/">杂谈</a><span class="category-list-count">5</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/%E7%94%9F%E6%B4%BB%E5%AD%A6%E4%B9%A0/%E8%AF%BB%E4%B9%A6/">读书</a><span class="category-list-count">1</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/%E7%94%9F%E6%B4%BB%E5%AD%A6%E4%B9%A0/%E9%9F%B3%E4%B9%90/">音乐</a><span class="category-list-count">2</span></li></ul></li><li class="category-list-item"><a class="category-list-link" href="/categories/%E7%BB%8F%E9%AA%8C%E6%95%99%E7%A8%8B/">经验教程</a><span class="category-list-count">16</span><ul class="category-list-child"><li class="category-list-item"><a class="category-list-link" href="/categories/%E7%BB%8F%E9%AA%8C%E6%95%99%E7%A8%8B/%E5%8D%9A%E5%AE%A2/">博客</a><span class="category-list-count">5</span></li></ul></li><li class="category-list-item"><a class="category-list-link" href="/categories/%E7%BC%96%E7%A8%8B%E5%9F%BA%E7%A1%80/">编程基础</a><span class="category-list-count">39</span><ul class="category-list-child"><li class="category-list-item"><a class="category-list-link" href="/categories/%E7%BC%96%E7%A8%8B%E5%9F%BA%E7%A1%80/C-%E5%9F%BA%E7%A1%80/">C++基础</a><span class="category-list-count">7</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/%E7%BC%96%E7%A8%8B%E5%9F%BA%E7%A1%80/linux%E5%9F%BA%E7%A1%80/">linux基础</a><span class="category-list-count">11</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/%E7%BC%96%E7%A8%8B%E5%9F%BA%E7%A1%80/%E6%95%B0%E6%8D%AE%E5%BA%93/">数据库</a><span class="category-list-count">4</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/%E7%BC%96%E7%A8%8B%E5%9F%BA%E7%A1%80/%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84%E4%B8%8E%E7%AE%97%E6%B3%95/">数据结构与算法</a><span class="category-list-count">9</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/%E7%BC%96%E7%A8%8B%E5%9F%BA%E7%A1%80/%E7%BD%91%E7%BB%9C%E7%BC%96%E7%A8%8B/">网络编程</a><span class="category-list-count">2</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/%E7%BC%96%E7%A8%8B%E5%9F%BA%E7%A1%80/%E8%AE%BE%E8%AE%A1%E6%A8%A1%E5%BC%8F/">设计模式</a><span class="category-list-count">4</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/%E7%BC%96%E7%A8%8B%E5%9F%BA%E7%A1%80/%E8%BD%AF%E4%BB%B6%E5%B7%A5%E7%A8%8B/">软件工程</a><span class="category-list-count">2</span></li></ul></li><li class="category-list-item"><a class="category-list-link" href="/categories/%E8%B5%84%E6%BA%90%E5%88%86%E4%BA%AB/">资源分享</a><span class="category-list-count">2</span><ul class="category-list-child"><li class="category-list-item"><a class="category-list-link" href="/categories/%E8%B5%84%E6%BA%90%E5%88%86%E4%BA%AB/%E5%BC%80%E5%8F%91%E8%B5%84%E6%BA%90/">开发资源</a><span class="category-list-count">1</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/%E8%B5%84%E6%BA%90%E5%88%86%E4%BA%AB/%E6%BA%90%E7%A0%81/">源码</a><span class="category-list-count">1</span></li></ul></li></ul>
</aside>
<aside id="krw-tags" class="widget widget-kratos-tags clearfix">
<h4 class="widget-title"><i class="fa fa-tags"></i>标签云</h4>
<div class="tag-clouds">
<a href="/tags/ACGN/" style="font-size: 0.75em;">ACGN</a> <a href="/tags/ACM/" style="font-size: 0.6em;">ACM</a> <a href="/tags/AVL%E6%A0%91/" style="font-size: 0.6em;">AVL树</a> <a href="/tags/C/" style="font-size: 0.6em;">C++</a> <a href="/tags/C-%E5%9F%BA%E7%A1%80/" style="font-size: 0.8em;">C++基础</a> <a href="/tags/C-%E7%B1%BB%E5%9E%8B/" style="font-size: 0.65em;">C++类型</a> <a href="/tags/IO%E5%A4%9A%E8%B7%AF%E5%A4%8D%E7%94%A8/" style="font-size: 0.65em;">IO多路复用</a> <a href="/tags/IO%E6%A8%A1%E5%9E%8B/" style="font-size: 0.6em;">IO模型</a> <a href="/tags/MYSQL/" style="font-size: 0.65em;">MYSQL</a> <a href="/tags/SAO/" style="font-size: 0.6em;">SAO</a> <a href="/tags/adb/" style="font-size: 0.6em;">adb</a> <a href="/tags/anacron/" style="font-size: 0.6em;">anacron</a> <a href="/tags/centos/" style="font-size: 0.7em;">centos</a> <a href="/tags/cms/" style="font-size: 0.6em;">cms</a> <a href="/tags/cron/" style="font-size: 0.6em;">cron</a> <a href="/tags/crontab/" style="font-size: 0.6em;">crontab</a> <a href="/tags/epoll/" style="font-size: 0.6em;">epoll</a> <a href="/tags/gcc/" style="font-size: 0.6em;">gcc</a>
</div>
</aside>
<aside id="krw-posts" class="widget widget-kratos-poststab">
<h4 class="widget-title"><i class="fa fa-file"></i>最新文章</h4>
<div class="tab-content">
<ul class="list-group">
<a class="list-group-item" href="/20230825-1.html"><i class="fa fa-book"></i> 工作中遇到的一些数据库问题记录(随时更新)</a>
<a class="list-group-item" href="/20230508-1.html"><i class="fa fa-book"></i> C++开源游戏服务器或脚手架记录</a>
<a class="list-group-item" href="/20230302-1.html"><i class="fa fa-book"></i> ubuntu scp命令的一个问题</a>
<a class="list-group-item" href="/20230227-1.html"><i class="fa fa-book"></i> linux僵尸进程和孤儿进程一点记录</a>
<a class="list-group-item" href="/20230224-1.html"><i class="fa fa-book"></i> 关于带返回值的函数未返回引起的Undefined Behavior问题</a>
</ul>
</div>
</aside>
</section>
</div>
</div>
</div>
<footer>
<div id="footer">
<div class="kr-tool text-center">
<div class="tool">
<div class="box search-box">
<a href="/search/">
<span class="fa fa-search"></span>
</a>
</div>
<div class="box theme-box" id="darkmode-switch">
<span class="fa fa-adjust"></span>
</div>
</div>
<div class="box gotop-box">
<span class="fa fa-chevron-up"></span>
</div>
</div>
<div class="container">
<div class="row">
<div class="col-md-6 col-md-offset-3 footer-list text-center">
<ul class="kratos-social-icons text-center">
<li><a href="mailto:[email protected]"><i class="fa fa-envelope"></i></a></li>
<li><a target="_blank" rel="me" href="https://smp.chaoswork.cn/@stayknight"><i class="fa fa fa-share-alt-square"></i></a></li>
<li><a target="_blank" rel="nofollow" href="https://github.com/stayknight"><i class="fa fa-github"></i></a></li>
<li><a target="_blank" rel="nofollow" href="/atom.xml"><i class="fa fa-rss"></i></a></li>
</ul>
<ul class="kratos-copyright">
<div>
<li>© 2023 云海鹰影 版权所有.</li>
<li>本站已运行<span id="span_dt">Loading...</span></li>
</div>
<div>
<li>Theme <a href="https://github.com/Candinya/Kratos-Rebirth" target="_blank">Kratos:Rebirth</a></li>
<li>Made with <i class="fa fa-heart throb" style="color:#d43f57"></i> by <a href="https://candinya.com" target="_blank" rel="nofollow">Candinya</a>.</li>
</div>
<div>
<li>Powered by <a href="https://hexo.io" target="_blank" rel="nofollow">Hexo</a></li>
<li>Hosted on <a href="https://github.io" target="_blank">Github Pages</a></li>
</div>
<div>
<li><a href="https://beian.miit.gov.cn" rel="external nofollow" target="_blank">鄂ICP备17025858号-5</a></li>
<li><a href="http://www.beian.gov.cn" rel="external nofollow" target="_blank"><img src="/images/psr.webp" width="12" height="12"> xxxxx</a></li>
<li><a href="sitemap.xml" target="_blank">站点地图</a></li>
<li><a href="baidusitemap.xml" target="_blank">百度地图</a></li>
</div>
</ul>
</div>
</div>
</div>
</div>
</footer>
</div>
</div>
<script type="text/javascript" charset="utf-8">
$("img.headicon").one("error", function(e) {
$(this).attr("src", "/images/avatar.webp");
});
</script>
<script defer src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js"></script>
<script defer src="https://cdn.jsdelivr.net/npm/[email protected]/nprogress.min.js"></script>
<script>const notMobile = (!(navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i)));</script>
<div>
<canvas id="snow"></canvas>
<script async type="text/javascript" src="/js/snow.min.js"></script>
</div>
<script async src="/js/candy.min.js"></script>
<script defer src=""></script>
<script defer src="https://cdn.jsdelivr.net/npm/[email protected]/dist/clipboard.min.js"></script>
<script defer src="/js/kratosr.min.js"></script>
<script defer src="/js/pjax.min.js"></script>
<script defer src="/js/kr-dark.min.js"></script>
<script>
var _hmt = _hmt || [];
(function() {
var hm = document.createElement("script");
hm.src = "//hm.baidu.com/hm.js?bfb917536df0b5a503a5690e6de9ef9c";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(hm, s);
})();
</script>
</body>
</html>