服务器之家:专注于服务器技术及软件下载分享
分类导航

Linux|Centos|Ubuntu|系统进程|Fedora|注册表|Bios|Solaris|Windows7|Windows10|Windows11|windows server|

服务器之家 - 服务器系统 - Linux - 如何使用ssh_scan远程验证SSH服务的配置和策略

如何使用ssh_scan远程验证SSH服务的配置和策略

2023-10-18 18:13未知服务器之家 Linux

导读 ssh_scan是一个面向和 UNIX 服务器的易用的 SSH 服务参数配置和策略的扫描器程序,其思路来自Mozilla OpenSSH安全指南,这个指南为 SSH 服务参数配置提供了一个可靠的安全策略基线的建议,如加密算法(Ciphers),报文认证信息码

导读 ssh_scan是一个面向 和 UNIX 服务器的易用的 SSH 服务参数配置和策略的扫描器程序,其思路来自Mozilla OpenSSH安全指南,这个指南为 SSH 服务参数配置提供了一个可靠的安全策略基线的建议,如加密算法(Ciphers),报文认证信息码算法(MAC),密钥交换算法(KexAlgos)和其它。

如何使用ssh_scan远程验证SSH服务的配置和策略

ssh_scan有如下好处:

  • 它的依赖是最小化的,ssh_scan只引入了本地 Ruby 和 BinData 来进行它的工作,没有太多的依赖。
  • 它是可移植的,你可以在其它的项目中使用ssh_scan或者将它用在自动化任务上。
  • 它是易于使用的,只需要简单的将它指向一个 SSH 服务就可以获得一个该服务所支持的选项和策略状态的 JSON 格式报告。
  • 它同时也是易于配置的,你可以创建适合你策略需求的策略。

建议阅读:如何在 Linux 上安装配置 OpenSSH 服务

如何在 Linux 上安装 ssh_scan

有如下三种安装ssh_scan 的方式:

使用 Ruby gem 来安装运行,如下:

-----------在Debian/Ubuntu-----------
$sudoapt-getinstallrubygem
$sudogeminstallssh_scan
-----------在CentOS/RHEL-----------
#yuminstallrubyrubygem
#geminstallssh_scan

使用docker 容器来运行,如下:

#dockerpullmozilla/ssh_scan
#dockerrun-itmozilla/ssh_scan/app/bin/ssh_scan-tgithub.com

使用源码安装运行,如下:

#gitclone
#cdssh_scan
#gpg2--keyserverhkp://keys.gnupg.net--recv-keys409B6B1796C275462A1703113804BB82D39DC0E3
#curl-sSL|bash-sstable
#rvminstall2.3.1
#rvmuse2.3.1
#geminstallbundler
#bundleinstall
#./bin/ssh_scan
如何在 Linux 上使用 ssh_scan

使用ssh_scan的语法如下:

$ssh_scan-tip地址
$ssh_scan-t主机名

举个例子来扫描 192.168.43.198 这台服务器的 SSH 配置和策略,键入:

$ssh_scan-t192.168.43.198

注意你同时也可以像下方展示的给 -t选项传入一个[IP地址/地址段/主机名]:

$ssh_scan-t192.168.43.198,200,205
$ssh_scan-ttest.tecmint.lan

输出示例:

I,[2017-05-09T10:36:17.913644#7145]INFO--:You'reusingthelatestversionofssh_scan0.0.19
[
{
"ssh_scan_version":"0.0.19",
"ip":"192.168.43.198",
"port":22,
"server_banner":"SSH-2.0-OpenSSH_7.2p2Ubuntu-4ubuntu2.1",
"ssh_version":2.0,
"os":"ubuntu",
"os_cpe":"o:canonical:ubuntu:16.04",
"ssh_lib":"openssh",
"ssh_lib_cpe":"a:openssh:openssh:7.2p2",
"cookie":"68b17bcca652eeaf153ed18877770a38",
"key_algorithms":[
"curve25519-sha256@libssh.org",
"ecdh-sha2-nistp256",
"ecdh-sha2-nistp384",
"ecdh-sha2-nistp521",
"diffie-hellman-group-exchange-sha256",
"diffie-hellman-group14-sha1"
],
"server_host_key_algorithms":[
"ssh-rsa",
"rsa-sha2-512",
"rsa-sha2-256",
"ecdsa-sha2-nistp256",
"ssh-ed25519"
],
"encryption_algorithms_client_to_server":[
"chacha20-poly1305@openssh.com",
"aes128-ctr",
"aes192-ctr",
"aes256-ctr",
"aes128-gcm@openssh.com",
"aes256-gcm@openssh.com"
],
"encryption_algorithms_server_to_client":[
"chacha20-poly1305@openssh.com",
"aes128-ctr",
"aes192-ctr",
"aes256-ctr",
"aes128-gcm@openssh.com",
"aes256-gcm@openssh.com"
],
"mac_algorithms_client_to_server":[
"umac-64-etm@openssh.com",
"umac-128-etm@openssh.com",
"hmac-sha2-256-etm@openssh.com",
"hmac-sha2-512-etm@openssh.com",
"hmac-sha1-etm@openssh.com",
"umac-64@openssh.com",
"umac-128@openssh.com",
"hmac-sha2-256",
"hmac-sha2-512",
"hmac-sha1"
],
"mac_algorithms_server_to_client":[
"umac-64-etm@openssh.com",
"umac-128-etm@openssh.com",
"hmac-sha2-256-etm@openssh.com",
"hmac-sha2-512-etm@openssh.com",
"hmac-sha1-etm@openssh.com",
"umac-64@openssh.com",
"umac-128@openssh.com",
"hmac-sha2-256",
"hmac-sha2-512",
"hmac-sha1"
],
"compression_algorithms_client_to_server":[
"none",
"zlib@openssh.com"
],
"compression_algorithms_server_to_client":[
"none",
"zlib@openssh.com"
],
"languages_client_to_server":[
],
"languages_server_to_client":[
],
"hostname":"tecmint",
"auth_methods":[
"publickey",
"password"
],
"fingerprints":{
"rsa":{
"known_bad":"false",
"md5":"0e:d0:d7:11:f0:9b:f8:33:9c:ab:26:77:e5:66:9e:f4",
"sha1":"fc:8d:d5:a1:bf:52:48:a6:7e:f9:a6:2f:af:ca:e2:f0:3a:9a:b7:fa",
"sha256":"ff:00:b4:a4:40:05:19:27:7c:33:aa:db:a6:96:32:88:8e:bf:05:a1:81:c0:a4:a8:16:01:01:0b:20:37:81:11"
}
},
"start_time":"2017-05-0910:36:17+0300",
"end_time":"2017-05-0910:36:18+0300",
"scan_duration_seconds":0.221573169,
"duplicate_host_key_ips":[
],
"compliance":{
"policy":"MozillaModern",
"compliant":false,
"recommendations":[
"RemovetheseKeyExchangeAlgos:diffie-hellman-group14-sha1",
"RemovetheseMACAlgos:umac-64-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,hmac-sha1",
"RemovetheseAuthenticationMethods:password"
],
"references":[
"https://wiki.mozilla.org/Security/Guidelines/OpenSSH"
]
}
}
]

你可以使用-p选项来指定不同的端口,-L选项来开启日志记录配合-V选项来指定日志级别:

$ssh_scan-t192.168.43.198-p22222-Lssh-scan.log-VINFO

另外,可以使用-P或--policy选项来指定一个策略文件(默认是 Mozilla Modern):

$ssh_scan-t192.168.43.198-Lssh-scan.log-VINFO-P/path/to/custom/policy/file

ssh_scan 使用帮助与其它示例:

$ssh_scan-h

输出示例:

ssh_scanv0.0.17()
Usage:ssh_scan[options]
-t,--target[IP/Range/Hostname]IP/Ranges/Hostnametoscan
-f,--file[FilePath]FilePathofthefilecontainingIP/Range/Hostnamestoscan
-T,--timeout[seconds]Timeoutperconnectafterwhichssh_scangivesuponthehost
-L,--logger[LogFilePath]Enablelogger
-O,--from_json[FilePath]FiletoreadJSONoutputfrom
-o,--output[FilePath]FiletowriteJSONoutputto
-p,--port[PORT]Port(Default:22)
-P,--policy[FILE]Custompolicyfile(Default:MozillaModern)
--threads[NUMBER]Numberofworkerthreads(Default:5)
--fingerprint-db[FILE]Filelocationoffingerprintdatabase(Default:./fingerprints.db)
--suppress-update-statusDonotcheckforupdates
-u,--unit-test[FILE]Throwappropriateexitcodesbasedoncompliancestatus
-V[STD_LOGGING_LEVEL],
--verbosity
-v,--versionDisplayjustversioninfo
-h,--helpShowthismessage
Examples:
ssh_scan-t192.168.1.1
ssh_scan-tserver.example.com
ssh_scan-t::1
ssh_scan-t::1-T5
ssh_scan-fhosts.txt
ssh_scan-ooutput.json
ssh_scan-Ooutput.json-orescan_output.json
ssh_scan-t192.168.1.1-p22222
ssh_scan-t192.168.1.1-p22222-Loutput.log-VINFO
ssh_scan-t192.168.1.1-Pcustom_policy.yml
ssh_scan-t192.168.1.1--unit-test-Pcustom_policy.yml

SSH 服务器相关参考阅读:

  1. 使用 SSH Keygen(ssh-keygen)五步实现 SSH 免密登录
  2. 安全 SSH 服务器的 5 个最 佳实践
  3. 使用 Chroot 来限制 SSH 用户进入某些目录
  4. 如何配置 SSH 连接来简化远程登录

via:

作者: 译者: 校对:

本文由 原创编译, 荣誉推出

原文来自:


延伸 · 阅读

精彩推荐
  • Linux在Linux中使用Inxi获取系统和硬件信息的教程

    在Linux中使用Inxi获取系统和硬件信息的教程

    这篇文章主要介绍了在Linux中使用Inxi获取系统和硬件信息的教程,Inxi能够读取包括系统中的进程和内存占用情况等内容,需要的朋友可以参考下 ...

    Linux教程网6372019-10-09
  • LinuxSaltstack批量管理文件和计划任务

    Saltstack批量管理文件和计划任务

    saltstack是由thomas Hatch于创建的一个开源项目,设计初衷是为了实现一个快速的远程执行系统。用来管理你的基础架构,可轻松管理成千上万台服务器。本文...

    老实说运维5122021-01-08
  • LinuxLinux ifconfig 命令的使用

    Linux ifconfig 命令的使用

    这篇文章主要介绍了Linux ifconfig 命令的使用,帮助大家更好的理解和使用Linux系统,感兴趣的朋友可以了解下...

    Dabelv6392020-09-01
  • Linux如何更改SSH服务器远程登陆设置

    如何更改SSH服务器远程登陆设置

    为了系统安全,我们通常都会修改这些默认的设置,下面就说下怎么修改ssh的配置。实验用的系统为CentOS6.9,其他的Linux也可以参考。...

    三世浮华6872021-06-01
  • LinuxLinux 硬链接和软链接详细介绍

    Linux 硬链接和软链接详细介绍

    这篇文章主要介绍了Linux 硬链接和软链接详细介绍的相关资料,需要的朋友可以参考下...

    Linux教程网6852021-11-22
  • Linux详解linux 摄像头驱动编写

    详解linux 摄像头驱动编写

    本篇文章主要介绍了详解linux 摄像头驱动编写,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧...

    feixiaoxing5412022-03-07
  • LinuxLinux下apache不区分大小写办法

    Linux下apache不区分大小写办法

    在linux下,路径是区分大小写的,今天我们来把它改成不区分大小写的方法吧,有需要的朋友可以参考一下。 linux是区分大小写,下面是让aparch不区分路径...

    服务器之家4572020-04-12
  • Linuxlinux下用Proftpd搭建ftp服务器及配置

    linux下用Proftpd搭建ftp服务器及配置

    linux下搭建ftp服务器的软件是wuftp,现在真的时代变了,上网看一下几乎全世界的人都用proftpd了!赶个潮流,我也用proftpd在公司的一台备用小服务器上装上...

    Linux教程网3982019-12-28