We're going through a compliance audit and one of the requirements is that IgnoreRhosts
is set to yes
in sshd_config.
The pentest scanner has parsed the sshd_config file and determined the string doesn't exist, even though it does.
In the course of troubleshooting, I've stripped out just that line into a new file, and still can't get grep to match it for some reason
[root@xxxxx ~]# cat test
IgnoreRhosts yes
[root@xxxxx ~]# cat test | grep "^[\s]*(?i)IgnoreRhosts(?-i)[\s]+yes[\s]*$"
(nothing is returned)
Removing bits of the expression one by one still doesn't return a response until it's effectively all removed:
[root@xxxxx ~]# cat test | grep "^[\s]*(?i)IgnoreRhosts(?-i)[\s]+yes[\s]*$"
[root@xxxxx ~]# cat test | grep "^[\s]*(?i)IgnoreRhosts(?-i)[\s]"
[root@xxxxx ~]# cat test | grep "[\s]*(?i)IgnoreRhosts(?-i)[\s]"
[root@xxxxx ~]# cat test | grep "(?i)IgnoreRhosts(?-i)[\s]"
[root@xxxxx ~]# cat test | grep "(?i)IgnoreRhosts(?-i)"
[root@xxxxx ~]# cat test | grep "IgnoreRhosts"
IgnoreRhosts yes
Putting aside the SSH config part of the equation, why isn't grep matching this basic string? I've tried looking at the file with od
and hexdump
in case there were hidden characters, encoding problems, etc - but still cannot get grep to match that single line in an otherwise empty test file.
When I use an online regex validator, it matches immediately. Is this a bug in cat or grep perhaps? The server is running RHEL 8.6.