如何确定我的 ssh 服务器支持的 MAC、密码、密钥长度和 KexAlogrithms?
我需要为外部安全审计创建一个列表。我正在寻找类似于openssl s_client -connect example.com:443 -showcerts. 根据我的研究,ssh它使用 中列出的默认密码man sshd_config。但是,我需要一个可以在脚本中使用的解决方案,。我需要在这里更正自己:您可以man sshd_config并且没有列出有关密钥长度的信息ServerKeyBits在sshd_config.
我想这会ssh -vv localhost &> ssh_connection_specs.out返回我需要的信息,但我不确定列出的密码是客户端还是服务器支持的密码。另外我不确定如何在脚本中运行这个非交互式。
有没有方便的方法来获取SSH连接信息?
Jak*_*uje 21
您在问题中遗漏了几点:
ServerKeyBits 是协议版本 1 的选项,您希望将其禁用!支持的密码、MAC 和 KexAlgorithms 始终在手册中可用,这与密钥长度没有任何共同之处。
正如您所指出的,启用的芯片、MAC 和 KexAlgorithms 是使用连接提供的。但是它们也可以通过其他方式获得,例如使用sshd -T | grep "\(ciphers\|macs\|kexalgorithms\)"
要获取服务器密钥的密钥长度,您可以使用 ssh-keygen: ssh-keygen -lf /etc/ssh/ssh_host_rsa_key.pub
但是您可能还需要密钥交换期间提供和使用的模数大小,但这实际上取决于密钥交换方法,但它也应该可以从调试输出中读取ssh -vvv host。
Sté*_*hon 18
如何确定我的 ssh 服务器支持的 MAC、密码、密钥长度和 KexAlogrithms?
看起来https://superuser.com/a/1219759/173408上的答案也是您问题的答案。它适合一行:
nmap --script ssh2-enum-algos -sV -p 22 1.2.3.4
Run Code Online (Sandbox Code Playgroud)
这是具有当前 SSH 版本的普通 Debian 9.4 机器上的输出:
在 2018-05-22 13:40 CEST 开始 Nmap 7.01 ( https://nmap.org ) 1.2.3.4 的 Nmap 扫描报告 主机已启动(0.00024 秒延迟)。 港口国服务版本 22/tcp 打开 ssh OpenSSH 7.4p1 Debian 10+deb9u3(协议 2.0) | ssh2 枚举算法: | kex_algorithms: (10) | 曲线25519-sha256 | curve25519-sha256@libssh.org | 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: (5) | ssh-rsa | rsa-sha2-512 | rsa-sha2-256 | ecdsa-sha2-nistp256 | ssh-ed25519 | 加密算法:(6) | chacha20-poly1305@openssh.com | aes128-ctr | aes192-ctr | aes256-ctr | aes128-gcm@openssh.com | aes256-gcm@openssh.com | mac_algorithms: (10) | 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 | 压缩算法:(2) | 没有任何 |_ zlib@openssh.com 服务信息:操作系统:Linux;CPE: cpe:/o:linux:linux_kernel 已执行服务检测。请在 https://nmap.org/submit/ 报告任何不正确的结果。 Nmap 完成:1 个 IP 地址(1 个主机启动)在 0.52 秒内扫描