File tree 4 files changed +33
-2
lines changed
4 files changed +33
-2
lines changed Original file line number Diff line number Diff line change @@ -76,10 +76,9 @@ override['ssh-hardening']['ssh']['server']['listen_to'] = node['ipaddress']
76
76
* ` ['ssh-hardening']['ssh']['server']['sftp']['enable'] ` - ` false ` . Set to ` true ` to enable the SFTP feature of OpenSSH daemon
77
77
* ` ['ssh-hardening']['ssh']['server']['sftp']['group'] ` - ` sftponly ` . Sets the ` Match Group ` option of SFTP to allow SFTP only for dedicated users
78
78
* ` ['ssh-hardening']['ssh']['server']['sftp']['chroot'] ` - ` /home/%u ` . Sets the directory where the SFTP user should be chrooted
79
-
79
+ * ` ['ssh-hardening']['ssh']['server']['authorized_keys_path'] ` - ` nil ` . If not nil, full path to an authorized keys folder is expected
80
80
* ` ['ssh-hardening']['ssh']['server']['extras'] ` - ` {} ` . Add extra configuration options, see [ below] ( #extra-configuration-options ) for details
81
81
82
-
83
82
## Usage
84
83
85
84
Add the recipes to the run_list:
Original file line number Diff line number Diff line change 105
105
server [ 'password_authentication' ] = false
106
106
server [ 'log_level' ] = 'verbose'
107
107
server [ 'accept_env' ] = [ 'LANG' , 'LC_*' , 'LANGUAGE' ]
108
+ server [ 'authorized_keys_path' ] = nil # if not nil, full path to an authorized keys folder is expected
108
109
109
110
# extra server configuration options
110
111
server [ 'extras' ] = { }
Original file line number Diff line number Diff line change 663
663
with_content ( /AcceptEnv some environment variables/ )
664
664
end
665
665
end
666
+
667
+ describe 'customized AuthorizedKeysFile option' do
668
+ context 'without customized AuthorizedKeysFile' do
669
+ cached ( :chef_run ) do
670
+ ChefSpec ::ServerRunner . new . converge ( described_recipe )
671
+ end
672
+
673
+ it 'does not have AuthorizedKeysFile configured' do
674
+ expect ( chef_run ) . not_to render_file ( '/etc/ssh/sshd_config' ) .
675
+ with_content ( 'AuthorizedKeysFile' )
676
+ end
677
+ end
678
+
679
+ context 'with customized AuthorizedKeysFile' do
680
+ cached ( :chef_run ) do
681
+ ChefSpec ::ServerRunner . new do |node |
682
+ node . normal [ 'ssh-hardening' ] [ 'ssh' ] [ 'server' ] [ 'authorized_keys_path' ] = '/some/authorizedkeysfile'
683
+ end . converge ( described_recipe )
684
+ end
685
+
686
+ it 'has AuthorizedKeysFile configured' do
687
+ expect ( chef_run ) . to render_file ( '/etc/ssh/sshd_config' ) .
688
+ with_content ( 'AuthorizedKeysFile /some/authorizedkeysfile' )
689
+ end
690
+ end
691
+ end
666
692
end
Original file line number Diff line number Diff line change @@ -96,6 +96,11 @@ MaxStartups 10:30:100
96
96
# Enable public key authentication
97
97
PubkeyAuthentication yes
98
98
99
+ <% if @node['ssh-hardening']['ssh']['server']['authorized_keys_path'] %>
100
+ # Customized authorized keys path
101
+ AuthorizedKeysFile <%= @node['ssh-hardening']['ssh']['server']['authorized_keys_path'] %>
102
+ <% end %>
103
+
99
104
# Never use host-based authentication. It can be exploited.
100
105
IgnoreRhosts yes
101
106
IgnoreUserKnownHosts yes
You can’t perform that action at this time.
0 commit comments