Security configuration of SSH login entry - enterprise security practice
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的更多相关文章
- Spring Security(十九):6. Security Namespace Configuration
6.1 Introduction Namespace configuration has been available since version 2.0 of the Spring Framewor ...
- Spring Security笔记:自定义Login/Logout Filter、AuthenticationProvider、AuthenticationToken
在前面的学习中,配置文件中的<http>...</http>都是采用的auto-config="true"这种自动配置模式,根据Spring Securit ...
- 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. ...
- 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 ...
- Fixing ssh login long delay
原文:http://injustfiveminutes.com/2013/03/13/fixing-ssh-login-long-delay/ For a long time I had a prob ...
- 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 ...
- Debian Security Advisory(Debian安全报告) DSA-4416-1 wireshark security update
Debian Security Advisory(Debian安全报告) DSA-4416-1 wireshark security update Package:wireshark CVE ID : ...
- Debian Security Advisory(Debian安全报告) DSA-4415-1 passenger security update
Debian Security Advisory(Debian安全报告) DSA-4415-1 passenger security update Package : passenger CVE I ...
- 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 ...
随机推荐
- Centos 7 安装jdk 配置环境变量
在Centos7 终端中,我们输入java -version可以看到java的版本,但是输入javac却没有反应 原因是系统中预装的是openjdk jre不是真正的jdk,所以还得自己装好,然后配置 ...
- Utrack声卡和机架包的调试
视频链接http://www.tudou.com/programs/view/giZZ7b2dhn4/ 关于怎么调试这个问题困扰了我几个月之久,也没人教我,我也不知道问谁,搜又搜不到,所幸现在解决了问 ...
- spring: 加载远程配置
通常在spring应用中,配置中的properties文件,都是打包在war包里的,部署规模较小,只有几台服务器时,这样并没有什么大问题.如果服务器多了,特别是集群部署时,如果要修改某一项配置,得重新 ...
- 前端见微知著番外篇:Bitbucket进行代码管控
说道代码管控,一般都会提到TFS.Git等,但是在这里我们将要用到Bitbucket,其实其操作方式和Git基本上一样,但是和TFS则有很大的不同了.但是原理基本上都是一致的. 这里我不会过多的涉及到 ...
- ios蓝牙开发(四)app作为外设被连接的实现-转发
代码下载: 原博客中大部分示例代码都上传到了github,地址是:https://github.com/coolnameismy/demo. 再上一节说了app作为central连接periphera ...
- 802.11 对于multicast 和 broadcast的处理
ethernet内部会有broadcast 和 multicast.这两种包都是一个STA向多个STA发包. 当没有wifi存在的时候,LAN口之间的broadcast 和 multicast是可靠转 ...
- mvc5+ef6+Bootstrap 项目心得--WebGrid
1.mvc5+ef6+Bootstrap 项目心得--创立之初 2.mvc5+ef6+Bootstrap 项目心得--身份验证和权限管理 3.mvc5+ef6+Bootstrap 项目心得--WebG ...
- 开源免费的HTML5游戏引擎——青瓷引擎(QICI Engine) 1.0正式版发布了!
青瓷引擎的成长 青瓷引擎自2015年4月项目启动开始,7月首次亮相2015年ChinaJoy,便得到业界的极大关注,随后开启限量测试,收到数百个开发者团队的试用申请及反馈,期间经历了18个内测版本,完 ...
- JavaScript函数劫持
一.为什么我会写这篇文章 这篇文章其实是在一个偶然的机会下发现了居然有JavaScript劫持这种东西,虽然这种东西在平时用的比较少,而且一般实用价值不高,但是在一些特殊的情况下还是要使用到的,所以在 ...
- operating expense & captial expenditure
营运成本(营业成本, operating expense, OPEX) 指的是运行企业的持续性.消耗性的支出,与之对照的是资本支出(captial expenditure, CAPEX).例如:购买影 ...