Chapter 16. cf.check_my_ssh

#!/var/cfengine/bin/cfagent -qKf

# cfengine-policy-description: TCP connect to localhost:22 should result in an SSH banner being displayed by the SSH server.

control:

    probessh = ( ReadTCP(localhost,22,"",1024) )


classes: 
            got_ssh_banner = ( RegCmp("SSH-.*","${probessh}") )
          

alerts:

    !got_ssh_banner::
        
        "Did not receive banner from SSH server"