ssh_scan:Linux 和 UNIX 服务器的 SSH 配置和策略扫描程序

[ad_1]

SSH(“Secure Shell”)协议是一种从一个系统安全远程登录到另一个系统的方法。 系统管理员和用户使用客户端-服务器架构格式的不安全网络上的安全通道来连接 SSH 客户端和 SSH 服务器。 安全 ssh 服务器是一项重要任务。 Mozilla 有一个名为 ssh_scan 的工具,它充当 SSHD 的原型 SSH 配置和策略扫描器。

ssh_scan 的好处

从项目主页:

  1. 最小依赖——使用原生 Ruby 和 BinData 来完成它的工作,没有重度依赖。
  2. 不仅仅是脚本——实现是可移植的,可用于另一个项目或任务的自动化。
  3. 简单 – 只需将 ssh_scan 指向 SSH 服务,即可获取有关其支持的内容及其策略状态的 JSON 报告。
  4. 可配置 – 制定适合您独特策略要求的自定义策略。

安装依赖

键入以下 apt-get 命令/apt 命令以在 Debian/Ubuntu Linux 上安装 ruby​​ 和 gem:
$ sudo apt-get install ruby gem

示例输出:

安装 ssh_scan

键入以下命令以将 ssh_scan 安装为 gem:
$ sudo gem install ssh_scan

示例输出:

如何使用 ssh_scan?

语法是:
$ ssh_scan -t ip
$ ssh_scan -t server
$ ssh_scan -t server1.cyberciti.biz

例如扫描安装在 192.168.2.15 的 ssh 服务器,输入:
$ ssh_scan -t 192.168.2.15

示例输出:

I, [2017-04-25T16:12:11.019160 #32317]  INFO -- : You're using the latest version of ssh_scan 0.0.19
[
  {
    "ssh_scan_version": "0.0.19",
    "ip": "192.168.2.15",
    "port": 22,
    "server_banner": "SSH-2.0-OpenSSH_7.4p1 Ubuntu-10",
    "ssh_version": 2.0,
    "os": "ubuntu",
    "os_cpe": "o:canonical:ubuntu",
    "ssh_lib": "openssh",
    "ssh_lib_cpe": "a:openssh:openssh:7.4p1",
    "cookie": "82d7cc908765f03154b10d5cdf14195a",
    "key_algorithms": [
      "curve25519-sha256",
      "[email protected]",
      "ecdh-sha2-nistp256",
      "ecdh-sha2-nistp384",
      "ecdh-sha2-nistp521",
      "diffie-hellman-group-exchange-sha256",
      "diffie-hellman-group16-sha512",
      "diffie-hellman-group18-sha512",
      "diffie-hellman-group14-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": [
      "[email protected]",
      "aes128-ctr",
      "aes192-ctr",
      "aes256-ctr",
      "[email protected]",
      "[email protected]"
    ],
    "encryption_algorithms_server_to_client": [
      "[email protected]",
      "aes128-ctr",
      "aes192-ctr",
      "aes256-ctr",
      "[email protected]",
      "[email protected]"
    ],
    "mac_algorithms_client_to_server": [
      "[email protected]",
      "[email protected]",
      "[email protected]",
      "[email protected]",
      "[email protected]",
      "[email protected]",
      "[email protected]",
      "hmac-sha2-256",
      "hmac-sha2-512",
      "hmac-sha1"
    ],
    "mac_algorithms_server_to_client": [
      "[email protected]",
      "[email protected]",
      "[email protected]",
      "[email protected]",
      "[email protected]",
      "[email protected]",
      "[email protected]",
      "hmac-sha2-256",
      "hmac-sha2-512",
      "hmac-sha1"
    ],
    "compression_algorithms_client_to_server": [
      "none",
      "[email protected]"
    ],
    "compression_algorithms_server_to_client": [
      "none",
      "[email protected]"
    ],
    "languages_client_to_server": [

    ],
    "languages_server_to_client": [

    ],
    "hostname": "m6700",
    "auth_methods": [
      "publickey",
      "password"
    ],
    "fingerprints": {
      "rsa": {
        "known_bad": "false",
        "md5": "1d:14:84:f0:c7:21:10:0e:30:d9:f9:59:6b:c3:95:97",
        "sha1": "70:ac:7c:2c:94:54:aa:09:f2:58:f3:48:f0:9e:f2:a0:a2:37:f1:0a",
        "sha256": "6d:d8:20:c6:8e:e7:db:0d:94:9d:34:66:ba:b7:9c:68:8a:ea:79:19:a6:0d:76:cc:ec:fe:82:21:68:a5:64:74"
      }
    },
    "start_time": "2017-04-25 16:12:11 +0000",
    "end_time": "2017-04-25 16:12:11 +0000",
    "scan_duration_seconds": 0.118730486,
    "duplicate_host_key_ips": [

    ],
    "compliance": {
      "policy": "Mozilla Modern",
      "compliant": false,
      "recommendations": [
        "Remove these Key Exchange Algos: curve25519-sha256, diffie-hellman-group16-sha512, diffie-hellman-group18-sha512, diffie-hellman-group14-sha256, diffie-hellman-group14-sha1",
        "Remove these MAC Algos: [email protected], [email protected], [email protected], hmac-sha1",
        "Remove these Authentication Methods: password"
      ],
      "references": [
        "https://wiki.mozilla.org/Security/Guidelines/OpenSSH"
      ]
    }
  }
]

要查看所有其他选项,请输入:
$ ssh_scan -h

示例输出:

ssh_scan v0.0.19 (https://github.com/mozilla/ssh_scan)

Usage: ssh_scan [options]
    -t, --target [IP/Range/Hostname] IP/Ranges/Hostname to scan
    -f, --file [FilePath]            File Path of the file containing IP/Range/Hostnames to scan
    -T, --timeout [seconds]          Timeout per connect after which ssh_scan gives up on the host
    -L, --logger [Log File Path]     Enable logger
    -O, --from_json [FilePath]       File to read JSON output from
    -o, --output [FilePath]          File to write JSON output to
    -p, --port [PORT]                Port (Default: 22)
    -P, --policy [FILE]              Custom policy file (Default: Mozilla Modern)
        --threads [NUMBER]           Number of worker threads (Default: 5)
        --fingerprint-db [FILE]      File location of fingerprint database (Default: ./fingerprints.db)
        --suppress-update-status     Do not check for updates
    -u, --unit-test [FILE]           Throw appropriate exit codes based on compliance status
    -V [STD_LOGGING_LEVEL],
        --verbosity
    -v, --version                    Display just version info
    -h, --help                       Show this message

Examples:

  ssh_scan -t 192.168.1.1
  ssh_scan -t server.example.com
  ssh_scan -t ::1
  ssh_scan -t ::1 -T 5
  ssh_scan -f hosts.txt
  ssh_scan -o output.json
  ssh_scan -O output.json -o rescan_output.json
  ssh_scan -t 192.168.1.1 -p 22222
  ssh_scan -t 192.168.1.1 -p 22222 -L output.log -V INFO
  ssh_scan -t 192.168.1.1 -P custom_policy.yml
  ssh_scan -t 192.168.1.1 --unit-test -P custom_policy.yml

如何保护和优化我的 OpenSSH 服务器?

  1. OpenSSH 安全最佳实践
  2. 要为 SSH 配置参数提供合理的基线策略建议,请参阅此页面

[ad_2]

Related Posts