免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
楼主: king_819
打印 上一主题 下一主题

Linux/unix安全优化的讨论与案例分享(获奖名单已公布) [复制链接]

论坛徽章:
381
CU十二周年纪念徽章
日期:2014-01-04 22:46:58CU大牛徽章
日期:2013-03-13 15:32:35CU大牛徽章
日期:2013-03-13 15:38:15CU大牛徽章
日期:2013-03-13 15:38:52CU大牛徽章
日期:2013-03-14 14:08:55CU大牛徽章
日期:2013-04-17 11:17:19CU大牛徽章
日期:2013-04-17 11:17:32CU大牛徽章
日期:2013-04-17 11:17:37CU大牛徽章
日期:2013-04-17 11:17:42CU大牛徽章
日期:2013-04-17 11:17:47CU大牛徽章
日期:2013-04-17 11:17:52CU大牛徽章
日期:2013-04-17 11:17:56
11 [报告]
发表于 2012-03-08 15:13 |只看该作者
本帖最后由 chenyx 于 2012-03-08 15:17 编辑

另外,ssh服务应该加固,ssh协议只用协议2,采用key的方式登录,禁止密码登陆以及root登陆,除了key方式以外的认证方式一律禁止.

论坛徽章:
0
12 [报告]
发表于 2012-03-08 15:17 |只看该作者
本帖最后由 king_819 于 2012-03-08 15:24 编辑

    先来贴一个关于freebsd系统的内核优化,freebsd系统相对于linux类的系统,内核已经算是很简洁了,但为了发挥它高效的性能,所以决定再对它的内核进行精简

一、内核编译


   优化内核,去掉不用的组件及设备驱动,以提高系统效率,首先使用uname -a查看本机的内核详细版本,使用dmesg查看

本机所有的硬件信息,并进行相应的记录,后续编辑内核文件时要用到
1.安装CVSUP:


最好在安装时装好cvsup;
freebsd# cd /usr/ports/net/cvsup-without-gui/
freebsd# make install clean


2.升级源码:


freebsd# ee /usr/share/examples/cvsup/stable-supfile
把:
default host=CHANGE_THIS.FreeBSD.org
改为:
default host=cvsup.FreeBSDchina.org
src-all
freebsd# ee /usr/share/examples/cvsup/ports-supfile
把:
default host=CHANGE_THIS.FreeBSD.org
改为:
default host=cvsup.FreeBSDchina.org
freebsd# cvsup -g -L 2 /usr/share/examples/cvsup/stable-supfile
或者  csup -g -L 2 /usr/share/examples/cvsup/stable-supfile
freebsd# cvsup -g -L 2 /usr/share/examples/cvsup/ports-supfile
freebsd# cd /usr/obj
freebsd# chflags -R noschg *
freebsd# rm -rf *


3.重新编译源码和内核


freebsd# cd /usr/src/sys/amd64(或i386---32位与64位,分别选择相应的)/conf/
freebsd# mkdir /root/kernels
freebsd# cp GENERIC /root/kernels/MYKERNEL
freebsd# cd /usr/src
freebsd# ln -s /root/kernels/MYKERNEL
freebsd# make buildworld    //编译所有的系统程序
freebsd# make buildkernel KERNCONF=MYKERNEL   //编译新的系统核心
freebsd# reboot
freebsd# make installkernel KERNCONF=MYKERNEL  //安裝新的系统核心
freebsd# make installworld   //安装新的系统程序
freebsd# reboot
重启系统用uname -a查看编辑后的内核是否是自己定制的内核;


编辑内核文件要注意的地方
device  em    # Broadcom BCM570xx Gigabit Ethernet  //加载网卡,一定要慎重,特别是远程
如果不确定网卡型号,可用dmesg |less 查看

如新内核有问题,可以还的原内核文件
mv /boot/kernel /boot/kernel.bak
mv /boot/kernel.old /boot/kernel



4、附上生产环境中优化后的内核文件:
  1. cpu  I686_CPU
  2. ident  MYKERNE

  3. device          pf
  4. device          pflog
  5. device          pfsync
  6. options         ALTQ
  7. options         ALTQ_CBQ
  8. options         ALTQ_RED
  9. options         ALTQ_RIO
  10. options         ALTQ_HFSC
  11. options         ALTQ_PRIQ
  12. options         ALTQ_NOPCC
  13. options         SC_DISABLE_REBOOT

  14. options         IPFIREWALL                           
  15. options         IPFIREWALL_DEFAULT_TO_ACCEPT         
  16. options         DUMMYNET                              
  17. options         HZ=1000

  18. options   IPSEC        #IP security
  19. device    crypto

  20. options  SCHED_ULE  # ULE scheduler
  21. options  PREEMPTION  # Enable kernel thread preemption
  22. options  INET   # InterNETworking
  23. options  SCTP   # Stream Control Transmission Protocol
  24. options  FFS   # Berkeley Fast Filesystem
  25. options  SOFTUPDATES  # Enable FFS soft updates support
  26. options  UFS_ACL   # Support for access control lists
  27. options  UFS_DIRHASH  # Improve performance on big directories
  28. options  UFS_GJOURNAL  # Enable gjournal-based UFS journaling
  29. options  MD_ROOT   # MD is a potential root device
  30. options  PROCFS   # Process filesystem (requires PSEUDOFS)
  31. options  PSEUDOFS  # Pseudo-filesystem framework
  32. options  COMPAT_43TTY  # BSD 4.3 TTY compat [KEEP THIS!]
  33. options  SCSI_DELAY=5000  # Delay (in ms) before probing SCSI
  34. options  KTRACE   # ktrace(1) support
  35. options  STACK   # stack(9) support
  36. options  SYSVSHM   # SYSV-style shared memory
  37. options  SYSVMSG   # SYSV-style message queues
  38. options  SYSVSEM   # SYSV-style semaphores
  39. options  P1003_1B_SEMAPHORES # POSIX-style semaphores
  40. options  _KPOSIX_PRIORITY_SCHEDULING # POSIX P1003_1B real-time extensions
  41. options  KBD_INSTALL_CDEV # install a CDEV entry in /dev
  42. options  ADAPTIVE_GIANT  # Giant mutex is adaptive.
  43. options  STOP_NMI  # Stop CPUS using NMI instead of IPI
  44. options  AUDIT   # Security event auditing

  45. # To make an SMP kernel, the next two lines are needed
  46. options  SMP   # Symmetric MultiProcessor Kernel
  47. device  apic   # I/O APIC

  48. # CPU frequency control
  49. device  cpufreq

  50. # Bus support.
  51. device  eisa
  52. device  pci

  53. # SCSI Controllers
  54. device  mpt  # LSI-Logic MPT-Fusion
  55. device  scbus  # SCSI bus (required for SCSI)
  56. device  ch  # SCSI media changers
  57. device  da  # Direct Access (disks)
  58. device  pass  # Passthrough device (direct SCSI access)
  59. device  ses  # SCSI Environmental Services (and SAF-TE)

  60. # atkbdc0 controls both the keyboard and the PS/2 mouse
  61. device  atkbdc  # AT keyboard controller
  62. device  atkbd  # AT keyboard
  63. device  psm  # PS/2 mouse

  64. device  vga  # VGA video card driver

  65. device  splash  # Splash screen and screen saver support

  66. # syscons is the default console driver, resembling an SCO console
  67. device  sc

  68. device  agp  # support several AGP chipsets

  69. # Power management support (see NOTES for more options)
  70. #device  apm
  71. # Add suspend/resume support for the i8254.
  72. device  pmtimer

  73. # PCI Ethernet NICs that use the common MII bus controller code.
  74. # NOTE: Be sure to keep the 'device miibus' line in order to use these NICs!
  75. device  miibus  # MII bus support
  76. device  em
  77. device  le  # Broadcom BCM570xx Gigabit Ethernet


  78. # Pseudo devices.
  79. device  loop  # Network loopback
  80. device  random  # Entropy device
  81. device  ether  # Ethernet support
  82. device  tun  # Packet tunnel.
  83. device  pty  # Pseudo-ttys (telnet etc)
  84. device  md  # Memory "disks"
  85. device  gif  # IPv6 and IPv4 tunneling
  86. device  bpf  # Berkeley packet filter

  87. # USB support
  88. device  uhci  # UHCI PCI->USB interface
  89. device  ohci  # OHCI PCI->USB interface
  90. device  ehci  # EHCI PCI->USB interface (USB 2.0)
  91. device  usb  # USB Bus (required)
  92. device  ukbd  # Keyboard
复制代码

论坛徽章:
0
13 [报告]
发表于 2012-03-08 15:21 |只看该作者
本帖最后由 king_819 于 2012-03-08 15:29 编辑
chenyx 发表于 2012-03-08 15:13
另外,ssh服务应该加固,ssh协议只用协议2,采用key的方式登录,禁止密码登陆以及root登陆,除了key方式以外的认 ...



ssh用key认证,再配合上sudo

论坛徽章:
0
14 [报告]
发表于 2012-03-08 15:22 |只看该作者
本帖最后由 king_819 于 2012-03-08 15:29 编辑
chenyx 发表于 2012-03-08 15:13
另外,ssh服务应该加固,ssh协议只用协议2,采用key的方式登录,禁止密码登陆以及root登陆,除了key方式以外的认 ...



ssh用key认证,再配合上sudo

论坛徽章:
381
CU十二周年纪念徽章
日期:2014-01-04 22:46:58CU大牛徽章
日期:2013-03-13 15:32:35CU大牛徽章
日期:2013-03-13 15:38:15CU大牛徽章
日期:2013-03-13 15:38:52CU大牛徽章
日期:2013-03-14 14:08:55CU大牛徽章
日期:2013-04-17 11:17:19CU大牛徽章
日期:2013-04-17 11:17:32CU大牛徽章
日期:2013-04-17 11:17:37CU大牛徽章
日期:2013-04-17 11:17:42CU大牛徽章
日期:2013-04-17 11:17:47CU大牛徽章
日期:2013-04-17 11:17:52CU大牛徽章
日期:2013-04-17 11:17:56
15 [报告]
发表于 2012-03-08 15:22 |只看该作者
回复 14# king_819


    sudo,不是sodu

论坛徽章:
0
16 [报告]
发表于 2012-03-08 15:25 |只看该作者
回复 15# chenyx

呵呵。。打反了


   

论坛徽章:
4
CU大牛徽章
日期:2013-03-13 15:29:07CU大牛徽章
日期:2013-03-13 15:29:49CU大牛徽章
日期:2013-03-13 15:30:192015年迎新春徽章
日期:2015-03-04 09:57:09
17 [报告]
发表于 2012-03-08 15:34 |只看该作者
目前遇到的安全问题,大都集中在弱口令上。
高端的黑客攻击基本没遇到过,内核提权之类的也没遇到过。

论坛徽章:
4
CU大牛徽章
日期:2013-03-13 15:29:07CU大牛徽章
日期:2013-03-13 15:29:49CU大牛徽章
日期:2013-03-13 15:30:192015年迎新春徽章
日期:2015-03-04 09:57:09
18 [报告]
发表于 2012-03-08 15:35 |只看该作者
自己编译的内核需要及时关注内核的安全更新,毕竟防患于未然。性能有提升,但增加了维护的工作量。

论坛徽章:
18
巳蛇
日期:2014-12-03 08:27:5115-16赛季CBA联赛之吉林
日期:2016-04-18 15:24:24qiaoba
日期:2016-06-17 17:41:1615-16赛季CBA联赛之八一
日期:2016-06-20 15:13:1415-16赛季CBA联赛之广夏
日期:2016-06-29 10:38:28极客徽章
日期:2016-12-07 14:03:4015-16赛季CBA联赛之吉林
日期:2017-03-06 13:47:55
19 [报告]
发表于 2012-03-08 15:45 |只看该作者
ssh更改端口,用key登录
sudo感觉就是个怪东西

论坛徽章:
0
20 [报告]
发表于 2012-03-08 16:04 |只看该作者
chenyx 发表于 2012-03-08 15:07
系统安全,有个原则,就是只开放必要的端口,其他的端口一律不开放.比如一个web服务,我们只开放22和80端口


这个防护还不够严格
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP