Securing SSH might be a topic for another day. This time I'll only go into ensuring that only selected Ciphers, MACs, and Algorithms are allowed and how to verify that changes are successful.
First of all, let's build up a small inventory using nmap:
[23:07:36 - archy@stealth-falcon ~]$ nmap -sV -p 22 -open 172.31.10.0/24
A brief explanation of the arguments:-sV: will probe open ports and try to determine the service's version.
-p: This specifies the port or port range to scan. I'll be going for one port only.
--open: This will only print out hosts where the port is actually open.
Now that we know what we're working with, let's configure the Ciphers, Algorithms, and MACs to lock down ssh. Depending on the number of servers you have, I recommend using the config management tool of your choice, be it ansible, puppet, chef, or any of the others.
Here are the corresponding lines in my sshd_config:
KexAlgorithms curve25519-sha256@libssh.org,diffie-hellman-group-exchange-sha256
Ciphers chacha20-poly1305@openssh.com,aes256-ctr
MACs hmac-sha2-512-etm@openssh.com,hmac-sha2-512
Now that the ssh-server should be configured, let's check if everything has been applied accordingly:
[23:09:15 - archy@stealth-falcon ~]$ nmap -sV -p 22 -open -script ssh2-enum-algos 172.31.10.0/24
This is what you should see in the output of a single host: [23:09:47 - archy@stealth-falcon ~]$ nmap -sV -p 22 -open -script ssh2-enum-algos hyv01.archyslife.lan
Starting Nmap 7.80 ( https://nmap.org ) at 2020-11-02 19:28 CET
Nmap scan report for hyv01.archyslife.lan (172.31.10.250)
Host is up (0.00059s latency).
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 7.4 (protocol 2.0)
| ssh2-enum-algos:
| kex_algorithms: (2)
| curve25519-sha256@libssh.org
| diffie-hellman-group-exchange-sha256
| server_host_key_algorithms: (5)
| ssh-rsa
| rsa-sha2-512
| rsa-sha2-256
| ecdsa-sha2-nistp256
| ssh-ed25519
| encryption_algorithms: (2)
| chacha20-poly1305@openssh.com
| aes256-ctr
| mac_algorithms: (2)
| hmac-sha2-512-etm@openssh.com
| hmac-sha2-512
| compression_algorithms: (2)
| none
|_ zlib@openssh.com
Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 0.35 seconds
This time, nmap will use the built-in script for discovering available SSH Algorightms, Ciphers, and MACs.
Feel free to comment and / or suggest a topic.
Comments
Post a Comment