catalog

. 引言
. 修改ssh端口
. 禁用root远程ssh登录
. 只使用SSH v2
. 限制用户的SSH访问
. 禁用.rhosts文件
. 禁用基于主机的身份验证
. 基于公私钥的证书登录
. Linux SSH配置基线检查

0. 引言

关于企业IT系统建设安全性问题在任何时候都不会成为一个过时的话题,企业在构建适合自己业务需求的IT系统之初以及整个IT系统生命周期内,系统的安全运行都是一项非常重要的工作,安全健康体检主要着眼于服务器的入口安全,SSH服务是目前类unix系统上使用最为广泛的远程安全登录服务之一,默认端口为tcp 22端口。由于远程管理的需要,很多防火墙都对外开放了22端口,这就使得SSH服务很容易成为黑客的攻击目标。为避免系统的SSH服务被黑客攻击,我们需要对SSH服务进行一些加固操作,以保证服务器的安全

Relevant Link:

http://xjsunjie.blog.51cto.com/999372/691330
http://security.zdnet.com.cn/security_zone/2009/1214/1556391.shtml
http://blog.chinaunix.net/uid-25723371-id-4542221.html
http://www.cyberciti.biz/faq/ssh-passwordless-login-with-keychain-for-scripts/
http://heyihome.blog.51cto.com/2657805/480885

1. 修改ssh端口

SSH的默认端口是tcp 22,从最佳实践的角度来说,将SSH入口端口修改为非默认值,有助于阻止黑客的恶意扫描攻击

. vim /etc/ssh/sshd_config
. 修改为port
//ssh_config和sshd_config必须同时修改成11220,重启ssh服务(service sshd restart)后方可生效

2. 禁用root远程ssh登录

从最佳实践的角度来说,入口点的身份授权应该遵循"最小化权限原则",即用户应该在准确识别自己的业务需要,创建并赋予帐号最小化仅仅够用的权限,使用这个帐号进行登录

. vim /etc/ssh/sshd_config
. 修改PermitRootLogin no
. 重启sshd服务: #servicesshd restart

没有必要使用root用户通过SSH远程登录,普通用户可以通过su或sudo(推荐)获得root级别的访问权,这样你可以得到完整的审计信息,谁通过sudo在系统上执行特权命令就会一清二楚

3. 只使用SSH v2

SSH协议的第一个版本(SSH v1或SSH-1)存在中间人攻击问题和安全漏洞,它已经被作废,应该避免使用SSH v1

. vim /etc/ssh/sshd_config
. 增加Protocol

这样启动sshd后就只会使用SSH协议的第二个版本(SSH v2或SSH-2)了

4. 限制用户的SSH访问

默认情况下,所有系统用户都可以用他们的密码或公钥通过SSH实现远程登录,但有时你创建的UNIX/Linux用户是用于ftp或email目的,如果不加限制,这些用户也可以使用ssh登录到系统

. vim /etc/ssh/sshd_config
. 增加AllowUsers root vivek jerry
//只允许root、vivek、jerry进行ssh登录

5. 禁用.rhosts文件

不要读取用户的~/.rhosts和~/.shosts文件,使用下面的设置更新sshd_config配置文件

. vim /etc/ssh/sshd_config
. IgnoreRhosts yes

SSH可以模拟过时的rsh命令的行为,rsh被公认为是不安全的远程访问协议,因此必须得禁用掉

Relevant Link:

https://www-uxsup.csx.cam.ac.uk/doc/remote_access/rhosts.html
http://www-01.ibm.com/support/knowledgecenter/SSEPGG_9.7.0/com.ibm.db2.luw.qb.server.doc/doc/t0007952.html?lang=zh
http://www.mcsr.olemiss.edu/unixhelp/tasks/3.6.1.2.html
http://www.cnblogs.com/itech/archive/2012/09/09/2678097.html

6. 禁用基于主机的身份验证

禁用基于主机的身份验证,使用下面的选项更新sshd_config配置文件

. vim /etc/ssh/sshd_config
. HostbasedAuthentication no

7. 基于公私钥的证书登录 

0x1: 证书登录的步骤

. 客户端生成证书:私钥和公钥,然后私钥放在客户端,妥当保存,一般为了安全,会设置一个密码,以后每次登录ssh服务器时,客户端都要输入密码解开私钥
ssh-keygen -t rsa
/*
rsa是一种密码算法,还有一种是dsa,证书登录常用的是rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): /home/user/.ssh/id_rsa
(生成私钥与公钥存放位置,使用哪个账户操作就放在哪个账户下面)
Enter passphrase (empty for no passphrase): 输入密码
Enter same passphrase again:再次输入密码
Your identification has been saved in /home/user/.ssh/id_rsa. (生成的私钥)
Your public key has been saved in /home/user/.ssh/id_rsa.pub. (生成的公钥)
The key fingerprint is:
76:04:4d:44:25:37:0f:b1:a5:b7:6e:63:d4:97:22:6b
*/ . 服务器添加信用公钥: 把客户端生成的公钥,上传到ssh服务器,添加到指定的文件中
将生成的公钥id_rsa.pub复制一份并重命名为authorized_keys放在服务器用户主文件夹的.ssh目录下
//假设客户端想通过私钥要登录其他ssh服务器,同理,可以把公钥上传到其他ssh服务器 . 重新启动ssh服务:/etc/init.d/ssh restart . 简化客户端putty、xshell配置
启动客户端连接软件,点击Advanced选项,选择User Keys,点击Import Key,在弹出的“打开”中找到刚刚复制到本地的id_rsa文件并打开。输入在制作这个私钥时设置的密码,输入完确定之后为该key命名,确定后设置此证书在本地发起连接时是否需要输入密码,如需要则设置,不需要就留空,最后点击Ok,本地证书就制作添加完成了

真实的工作中:员工生成好私钥和公钥(千万要记得设置私钥密码),然后把公钥发给运维人员,运维人员会登记你的公钥,为你开通一台或者多台服务器的权限,然后员工就可以通过一个私钥,登录他有权限的服务器做系统维护等工作,所以,员工是有责任保护他的私钥的
0x2: SSH配置加固

. vim /etc/ssh/sshd_config
. PermitEmptyPasswords no #不允许空密码用户login(仅仅是明文密码方式,非证书方式)
. RSAAuthentication yes #启用RSA认证
. PubkeyAuthentication yes #启用公钥认证
. PasswordAuthentication no #禁止密码认证
//补充: 修改vi /etc/ssh/ssh_config 文件(全局配置文件)
. RSAAuthentication yes # 允许RSA私钥方式认证
. PasswordAuthentication no #禁止明文密码登陆

Relevant Link:

http://www.edu.cn/jm_9957/20120508/t20120508_774165.shtml
http://www.jb51.net/LINUXjishu/72805.html
http://www.cnblogs.com/ggjucheng/archive/2012/08/19/2646346.html

8. Linux SSH配置基线检查

所有基线检查项都来自/etc/ssh/sshd_config

. port
) expectedvalue: 非22
) vul: 缺省(#)、或显式配置为22
) discription: 建议将ssh默认端口改为9999之后的非默认端口,防止黑客的恶意扫描 . PermitRootLogin
) expectedvalue: no
) vul: 缺省(#)、或显式配置为yes
) discription: 没有必要使用root用户通过SSH远程登录,普通用户可以通过su或sudo(推荐)获得root级别的访问权 . Protocol
) expectedvalue:
) vul: 显式配置为1
) discription: SSH协议的第一个版本(SSH v1或SSH-)存在中间人攻击问题和安全漏洞,它已经被作废,应该避免使用SSH v1 . IgnoreRhosts
) expectedvalue: yes
) vul: 显式配置为no
) discription: SSH可以模拟过时的rsh命令的行为,rsh被公认为是不安全的远程访问协议,因此必须得禁用掉 . HostbasedAuthentication
) expectedvalue: no
) vul: 显式配置为yes
) discription: 建议禁用基于主机的身份验证

Copyright (c) 2015 LittleHann All rights reserved

Security configuration of SSH login entry - enterprise security practice的更多相关文章

  1. Spring Security(十九):6. Security Namespace Configuration

    6.1 Introduction Namespace configuration has been available since version 2.0 of the Spring Framewor ...

  2. Spring Security笔记:自定义Login/Logout Filter、AuthenticationProvider、AuthenticationToken

    在前面的学习中,配置文件中的<http>...</http>都是采用的auto-config="true"这种自动配置模式,根据Spring Securit ...

  3. Security Configuration and Auditing Scripts for Oracle E-Business Suite (文档 ID 2069190.1)

    This document provides the security configuration and auditing scripts for Oracle E-Business Suite. ...

  4. REST Security with JWT using Java and Spring Security

    Security Security is the enemy of convenience, and vice versa. This statement is true for any system ...

  5. Fixing ssh login long delay

    原文:http://injustfiveminutes.com/2013/03/13/fixing-ssh-login-long-delay/ For a long time I had a prob ...

  6. Debian Security Advisory(Debian安全报告) DSA-4414-1 libapache2-mod-auth-mellon security update

    Debian Security Advisory(Debian安全报告) DSA-4414-1 libapache2-mod-auth-mellon security update Package:l ...

  7. Debian Security Advisory(Debian安全报告) DSA-4416-1 wireshark security update

    Debian Security Advisory(Debian安全报告) DSA-4416-1 wireshark security update Package:wireshark CVE ID : ...

  8. Debian Security Advisory(Debian安全报告) DSA-4415-1 passenger security update

    Debian Security Advisory(Debian安全报告) DSA-4415-1  passenger security update Package : passenger CVE I ...

  9. Debian Security Advisory(Debian安全报告) DSA-4412-1 drupal7 security update

    Debian Security Advisory(Debian安全报告) DSA-4412-1 drupal7 security update Package:drupal7 CVE ID:暂无 Dr ...

随机推荐

  1. 推薦使用 Microsoft Anti-Cross Site Scripting Library V3.0

    原文出至: http://blog.miniasp.com/post/2009/07/29/Recommand-Microsoft-Anti-Cross-Site-Scripting-Library- ...

  2. [转]使用URLDecoder和URLEncoder对中文进行处理

    一 URLEncoder HTML 格式编码的实用工具类.该类包含了将 String 转换为 application/x-www-form-urlencoded MIME 格式的静态方法.有关 HTM ...

  3. eclipse/intellij idea 远程调试hadoop 2.6.0

    很多hadoop初学者估计都我一样,由于没有足够的机器资源,只能在虚拟机里弄一个linux安装hadoop的伪分布,然后在host机上win7里使用eclipse或Intellj idea来写代码测试 ...

  4. sql 2012 提示列名无效 但可以执行问题

    笔者目前使用Ctrl+Shift+R可以解决这个问题,因为智能感知的问题,需要重新整理一下intellisense.有其他方法,请园友共享一下,谢谢. VS2012及13都有用到智能感知,而在sql里 ...

  5. Java 基础【08】.class getClass () forName() 详解

    类名.class是Class对象的句柄,每个被加载的类,在jvm中都会有一个Class对象与之相对应. 如果要创建新的对象,直接使用Class对象的局部class.forName就可以了,不需要用ne ...

  6. Data URI 应用场景小结

    Data URI scheme 在前端开发中是个常用的技术,通常会在 CSS 设置背景图中用到.比如在 Google 的首页就有用到: Data URI scheme 简称 Data URI,经常会被 ...

  7. Android闹钟设置的解决方案

    Android设置闹钟并不像IOS那样这么简单,做过Android设置闹钟的开发者都知道里面的坑有多深.下面记录一下,我解决Android闹钟设置的解决方案. 主要问题 API19开始AlarmMan ...

  8. REST API (from IBM)

    REST 本身是设计风格而不是标准.REST 谈论一件非常重要的事,如何正确地使用 Web标准,例如,HTTP 和 URI.想要了解 REST 最好的方式就是思索与了解 Web 及其工作方式.如果你设 ...

  9. java中的static详解

    如果一个类成员被声明为static,它就能够在类的任何对象创建之前被访问,而不必引用任何对象.static 成员的最常见的例子是main( ) .因为在程序开始执行时必须调用main() ,所以它被声 ...

  10. poj 1698 Alice‘s Chance

    poj 1698  Alice's Chance 题目地址: http://poj.org/problem?id=1698 题意: 演员Alice ,面对n场电影,每场电影拍摄持续w周,每周特定几天拍 ...