QuestionQ418

Application Deployment and Security

Drag the code snippets from the bottom to the blanks in the code to disable X11Forwarding on the SSH service of a CentOS server. Not every option is used.

Drag & Drop
state: present
state: enabled
state: disabled
line: "X11Forwarding yes"
line: "X11Forwarding no"
line: "X11Forwarding run"
state: absent
---
- name: Perform basic hardening tasks on a CentOS server
  hosts: hardening
  tasks:
    - name: Disable X11 forwarding
      lineinfile:
        path: "/etc/ssh/sshd_config"
        
        

    - name: Make sure X11 forwarding is absent
      lineinfile:
        path: "/etc/ssh/sshd_config"
        
        

    - name: Restart sshd, issue daemon-reload to pick-up config changes
      systemd:
        state: restarted
        daemon_reload: yes
        name: sshd
Explanation

X11Forwarding no disables X11 forwarding. Ansible lineinfile with state: present ensures that directive is in the file, and state: absent removes the conflicting X11Forwarding yes line. Restarting sshd applies the configuration.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!