Skip to content

Commit

Permalink
Avoid some deprecated options for OpenSSH >7.4
Browse files Browse the repository at this point in the history
E.g. on Ubuntu 18.04

Signed-off-by: Artem Sidorenko <artem@posteo.de>
  • Loading branch information
artem-sidorenko committed Jul 31, 2018
1 parent ceb147c commit 9bae0fe
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
14 changes: 7 additions & 7 deletions libraries/devsec_ssh.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,13 @@ def get_server_kexs(enable_weak = false)
get_crypto_data(:kexs, :server, enable_weak)
end

{ client: 'sshclient',
server: 'sshserver' }.each do |k, v|
define_method("get_ssh_#{k}_version") do
get_ssh_version(node['ssh-hardening'][v]['package'])
end
end

private

# :nocov:
Expand Down Expand Up @@ -170,13 +177,6 @@ def find_ssh_version(version, versions)
found_ssh_version
end

{ client: 'sshclient',
server: 'sshserver' }.each do |k, v|
define_method("get_ssh_#{k}_version") do
get_ssh_version(node['ssh-hardening'][v]['package'])
end
end

def get_ssh_version(package)
version = node['packages'][package]['version']
# on debian we get the epoch in front of version number: 1:7.2p2-4ubuntu2.1
Expand Down
3 changes: 2 additions & 1 deletion recipes/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@
{
mac: node['ssh-hardening']['ssh']['client']['mac'] || DevSec::Ssh.get_client_macs(node['ssh-hardening']['ssh']['client']['weak_hmac']),
kex: node['ssh-hardening']['ssh']['client']['kex'] || DevSec::Ssh.get_client_kexs(node['ssh-hardening']['ssh']['client']['weak_kex']),
cipher: node['ssh-hardening']['ssh']['client']['cipher'] || DevSec::Ssh.get_client_ciphers(node['ssh-hardening']['ssh']['client']['cbc_required'])
cipher: node['ssh-hardening']['ssh']['client']['cipher'] || DevSec::Ssh.get_client_ciphers(node['ssh-hardening']['ssh']['client']['cbc_required']),
version: DevSec::Ssh.get_client_ssh_version
}
end
)
Expand Down
3 changes: 3 additions & 0 deletions templates/default/openssh.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,13 @@ ForwardX11 no

# Never use host-based authentication. It can be exploited.
HostbasedAuthentication no

<% if @version.to_f < 7.4 %>
RhostsRSAAuthentication no

# Enable RSA authentication via identity files.
RSAAuthentication yes
<% end %>

# Disable password-based authentication, it can allow for potentially easier brute-force attacks.
PasswordAuthentication <%= ((@node['ssh-hardening']['ssh']['client']['password_authentication']) ? "yes" : "no" ) %>
Expand Down

0 comments on commit 9bae0fe

Please sign in to comment.