Skip to content
This repository has been archived by the owner on Dec 26, 2020. It is now read-only.

role creates duplicate parameter/values after run #124

Closed
todd-dsm opened this issue Jul 16, 2017 · 4 comments
Closed

role creates duplicate parameter/values after run #124

todd-dsm opened this issue Jul 16, 2017 · 4 comments

Comments

@todd-dsm
Copy link

Hey guys, I've just run this issue with a very basic configuration and found duplicates in /etc/ssh/sshd_config afterwards. The relevant details:

The OS:

$ lsb_release -id
Distributor ID:	Debian
Description:	Debian GNU/Linux 8.8 (jessie)

The configuration:

- name: Configure sshd and restart                                                 
  hosts: web                                                                       
  user: bob                                                                     
  become: yes                                                                      
  roles:                                                                           
    - role: dev-sec.ssh-hardening                                                  
      ssh_port: 22                                                                 
      ssh_use_pam: true                                                            
      sftp_enabled: true                                                           
      network_ipv6_enable: false                                                   

Duplicates

sudo egrep -v '^(#|$)' /etc/ssh/sshd_config | sort | uniq -d
    
AllowAgentForwarding no
AllowTcpForwarding no
PasswordAuthentication no
PermitRootLogin no
X11Forwarding no

Workaround

As I intend to use sftp early in the process, I've commented the duplicate parameters outside of the if sftp_enabled block.

egrep '(AllowAgentForwarding|AllowTcpForwarding|PasswordAuthentication|PermitRootLogin|X11Forwarding)' templates/opensshd.conf.j2
#PermitRootLogin {{ 'without-password' if ssh_allow_root_with_key else 'no' }}
#PasswordAuthentication {{ 'yes' if ssh_server_password_login else 'no' }}
#AllowTcpForwarding {{ 'yes' if ssh_allow_tcp_forwarding else 'no' }}
#AllowAgentForwarding {{ 'yes' if ssh_allow_agent_forwarding else 'no' }}
#X11Forwarding no
AllowTcpForwarding no
AllowAgentForwarding no
PasswordAuthentication no
PermitRootLogin no
X11Forwarding no

This is gross but it does eliminate the duplicates:

The ansible run output with -v has been included: ansible-sshd.txt

As always, I reserve the right to be completely in the wrong :-)

Please let me know if I've duffed it.

@rndmh3ro
Copy link
Member

Hey @todd-dsm,

that's expected id sftp is enabled. The duplicate parameters here only match the group sftponly. They can differ from the default values so should be separate (and thus duplicate).
If sftp is disabled, there should be no duplicate parameters.

Your workaround is potentially insecure, because you disabled the secure parameters for every ssh-login. They are only activated for sftp logins.

Hope it is clear what I'm trying to say :-).

@todd-dsm
Copy link
Author

Thanks for the update. I'll dig into it.

@rndmh3ro
Copy link
Member

rndmh3ro commented Aug 8, 2017

I'm closing this, since there's no error here. Feel free to reopen if you still have problems!

@rndmh3ro rndmh3ro closed this as completed Aug 8, 2017
@todd-dsm
Copy link
Author

todd-dsm commented Aug 9, 2017

totally, sorry that took so long.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants