码迷,mamicode.com
首页 > 其他好文 > 详细

sshd安全性能优化

时间:2016-09-13 20:56:10      阅读:256      评论:0      收藏:0      [点我收藏+]

标签:

  • sshd服务是远程登录服务,默认端口为22,对于其优化一是为了增加服务器的安全,避免暴力破解;二是为了加快速度连接,减少不必要的带宽的浪费。
     
  • sshd服务的配置文件为/etc/ssh/sshd_config,内容默认如下:
  1. # $OpenBSD: sshd_config,v 1.80 2008/07/02 02:24:18 djm Exp $
  2. # This is the sshd server system-wide configuration file.  See
  3. # sshd_config(5) for more information.
  4. # This sshd was compiled with PATH=/usr/local/bin:/bin:/usr/bin
  5. # The strategy used for options in the default sshd_config shipped with
  6. # OpenSSH is to specify options with their default value where
  7. # possible, but leave them commented.  Uncommented options change a
  8. # default value.
  9. #Port 22    修改一下默认端口,增强安全性。比如6688等。
  10. #AddressFamily any
  11. #ListenAddress 0.0.0.0    修改一下监听端口,默认是监听所有的IP,这样安全性不是很高,我们可以让它监听内网的Ip,这样即使有人知道系统用户的密码也无法连接进来。
  12. #ListenAddress ::
  13. # Disable legacy (protocol version 1) support in the server for new
  14. # installations. In future the default will change to require explicit
  15. # activation of protocol 1
  16. Protocol 2
  17. # HostKey for protocol version 1
  18. #HostKey /etc/ssh/ssh_host_key
  19. # HostKeys for protocol version 2
  20. #HostKey /etc/ssh/ssh_host_rsa_key
  21. #HostKey /etc/ssh/ssh_host_dsa_key
  22. # Lifetime and size of ephemeral version 1 server key
  23. #KeyRegenerationInterval 1h
  24. #ServerKeyBits 1024
  25. # Logging
  26. # obsoletes QuietMode and FascistLogging
  27. #SyslogFacility AUTH
  28. SyslogFacility AUTHPRIV
  29. #LogLevel INFO
  30. # Authentication:
  31. #LoginGraceTime 2m
  32. #PermitRootLogin yes    将其改为no,不让root用户远程登录。
  33. #StrictModes yes
  34. #MaxAuthTries 6
  35. #MaxSessions 10
  36. #RSAAuthentication yes
  37. #PubkeyAuthentication yes
  38. #AuthorizedKeysFile     .ssh/authorized_keys
  39. #AuthorizedKeysCommand none
  40. #AuthorizedKeysCommandRunAs nobody
  41. # For this to work you will also need host keys in /etc/ssh/ssh_known_hosts
  42. #RhostsRSAAuthentication no
  43. # similar for protocol version 2
  44. #HostbasedAuthentication no
  45. # Change to yes if you don‘t trust ~/.ssh/known_hosts for
  46. # RhostsRSAAuthentication and HostbasedAuthentication
  47. #IgnoreUserKnownHosts no
  48. # Don‘t read the user‘s ~/.rhosts and ~/.shosts files
  49. #IgnoreRhosts yes
  50. # To disable tunneled clear text passwords, change to no here!
  51. #PasswordAuthentication yes
  52. #PermitEmptyPasswords no
  53. PasswordAuthentication yes
  54. # Change to no to disable s/key passwords
  55. #ChallengeResponseAuthentication yes
  56. ChallengeResponseAuthentication no
  57. # Kerberos options
  58. #KerberosAuthentication no
  59. #KerberosOrLocalPasswd yes
  60. #KerberosTicketCleanup yes
  61. #KerberosGetAFSToken no
  62. #KerberosUseKuserok yes
  63. # GSSAPI options
  64. #GSSAPIAuthentication no
  65. GSSAPIAuthentication yes   将这个值改为no ,加快连接速度。
  66. #GSSAPICleanupCredentials yes
  67. GSSAPICleanupCredentials yes
  68. #GSSAPIStrictAcceptorCheck yes
  69. #GSSAPIKeyExchange no
  70. # Set this to ‘yes‘ to enable PAM authentication, account processing,
  71. # and session processing. If this is enabled, PAM authentication will
  72. # be allowed through the ChallengeResponseAuthentication and
  73. # PasswordAuthentication.  Depending on your PAM configuration,
  74. # PAM authentication via ChallengeResponseAuthentication may bypass
  75. # the setting of "PermitRootLogin without-password".
  76. # If you just want the PAM account and session checks to run without
  77. # PAM authentication, then enable this but set PasswordAuthentication
  78. # and ChallengeResponseAuthentication to ‘no‘.
  79. #UsePAM no
  80. UsePAM yes
  81. # Accept locale-related environment variables
  82. AcceptEnv LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES
  83. AcceptEnv LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT
  84. AcceptEnv LC_IDENTIFICATION LC_ALL LANGUAGE
  85. AcceptEnv XMODIFIERS
  86. #AllowAgentForwarding yes
  87. #AllowTcpForwarding yes
  88. #GatewayPorts no
  89. #X11Forwarding no
  90. X11Forwarding yes
  91. #X11DisplayOffset 10
  92. #X11UseLocalhost yes
  93. #PrintMotd yes
  94. #PrintLastLog yes
  95. #TCPKeepAlive yes
  96. #UseLogin no
  97. #UsePrivilegeSeparation yes
  98. #PermitUserEnvironment no
  99. #Compression delayed
  100. #ClientAliveInterval 0
  101. #ClientAliveCountMax 3
  102. #ShowPatchLevel no  
  103. #UseDNS yes                 将yes改为no,不适用dns,我们本来就是用ip访问的。
  104. #PidFile /var/run/sshd.pid
  105. #MaxStartups 10:30:100
  106. #PermitTunnel no
  107. #ChrootDirectory none
  108. # no default banner path
  109. #Banner none
  110. # override default of no subsystems
  111. Subsystem       sftp    /usr/libexec/openssh/sftp-server
  112. # Example of overriding settings on a per-user basis
  113. #Match User anoncvs
  114. #       X11Forwarding no
  115. #       AllowTcpForwarding no
  116. #       ForceCommand cvs server
 
总结:修改5个地方
1,默认端口           Port 52113
2,不使用dns解析  UseDNS no
3,不让root用户直接登录  PermitRootlogin no 
4,GSSAPI验证改为no GSSAPIAuthentication no
5, 监听端口ip 改为内网的Ip。

sshd安全性能优化

标签:

原文地址:http://www.cnblogs.com/lin1/p/5869659.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!