Skip to content

MQL Examples for authorizedkeys and authorizedkeys.entry #1179

Closed Answered by imilchev
kmf asked this question in Q&A
Discussion options

You must be logged in to vote

Here is an example policy that can do this:

policies:
  - uid: sshd-server-policy
    name: SSH Server Policy
    groups:
      - filters: platform.family.contains('linux') # will apply only to assets that run linux
        checks:
          - uid: ssh-authorized-keys
queries:
  - uid: ssh-authorized-keys
    title: Verify SSH authorized keys
    props:
      - uid: allowedKeys # a property that defines the allowed keys. It can be referenced in the query later
        title: Define allowed SSH keys
        mql: |
          return [ 
             "key1", 
             "key2"
          ]
    # The query loads the authorized keys file at /root/.ssh/authorized_keys and then creates a flat lis…

Replies: 3 comments 3 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@imilchev
Comment options

Answer selected by kmf
Comment options

You must be logged in to vote
2 replies
@kmf
Comment options

@imilchev
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants