As we reevaluate how to best support and maintain Staging Ref in the future, we encourage development teams using this environment to highlight their use cases in the following issue: https://gitlab.com/gitlab-com/gl-infra/software-delivery/framework/software-delivery-framework-issue-tracker/-/issues/36.

Skip to content
Snippets Groups Projects
Unverified Commit ece04aed authored by Ash McKenzie's avatar Ash McKenzie Committed by GitLab
Browse files

Merge branch '701-sshd-limit-server_host_key_algorithms-e-g-exclude-ssh-rsa' into 'main'

sshd: limit server_host_key_algorithms in server config

See merge request https://gitlab.com/gitlab-org/gitlab-shell/-/merge_requests/986



Merged-by: default avatarAsh McKenzie <amckenzie@gitlab.com>
Approved-by: default avatarAsh McKenzie <amckenzie@gitlab.com>
Reviewed-by: default avatarAsh McKenzie <amckenzie@gitlab.com>
Co-authored-by: default avatarJaviera Tapia <jtapia@gitlab.com>
parents 6cb97270 51fb61ba
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -98,6 +98,8 @@ sshd:
kex_algorithms: [curve25519-sha256, curve25519-sha256@libssh.org, ecdh-sha2-nistp256, ecdh-sha2-nistp384, ecdh-sha2-nistp521, diffie-hellman-group14-sha256, diffie-hellman-group14-sha1]
# Specified the ciphers allowed
ciphers: [aes128-gcm@openssh.com, chacha20-poly1305@openssh.com, aes256-gcm@openssh.com, aes128-ctr, aes192-ctr,aes256-ctr]
# Specified the available Public Key algorithms
public_key_algorithms: [ssh-rsa, ssh-dss, ecdsa-sha2-nistp256, sk-ecdsa-sha2-nistp256@openssh.com, ecdsa-sha2-nistp384, ecdsa-sha2-nistp521, ssh-ed25519, sk-ssh-ed25519@openssh.com, rsa-sha2-256, rsa-sha2-512]
# SSH host key files.
host_key_files:
- /run/secrets/ssh-hostkeys/ssh_host_rsa_key
Loading
Loading
Loading
Loading
@@ -47,6 +47,7 @@ type ServerConfig struct {
HostCertFiles []string `yaml:"host_cert_files,omitempty"`
MACs []string `yaml:"macs"`
KexAlgorithms []string `yaml:"kex_algorithms"`
PublicKeyAlgorithms []string `yaml:"public_key_algorithms"`
Ciphers []string `yaml:"ciphers"`
GSSAPI GSSAPIConfig `yaml:"gssapi,omitempty"`
}
Loading
Loading
Loading
Loading
@@ -266,6 +266,10 @@ func (s *serverConfig) get(ctx context.Context) *ssh.ServerConfig {
sshCfg.Ciphers = s.cfg.Server.Ciphers
}
if len(s.cfg.Server.PublicKeyAlgorithms) > 0 {
sshCfg.PublicKeyAuthAlgorithms = s.cfg.Server.PublicKeyAlgorithms
}
for _, key := range s.hostKeys {
sshCfg.AddHostKey(key)
}
Loading
Loading
Loading
Loading
@@ -266,6 +266,7 @@ func TestDefaultAlgorithms(t *testing.T) {
"aes192-ctr",
"aes256-ctr",
}
require.Equal(t, sshServerConfig.Ciphers, defaultCiphers)
}
Loading
Loading
@@ -273,13 +274,15 @@ func TestCustomAlgorithms(t *testing.T) {
customMACs := []string{"hmac-sha2-512-etm@openssh.com"}
customKexAlgos := []string{"curve25519-sha256"}
customCiphers := []string{"aes256-gcm@openssh.com"}
customPublicKeyAlgorithms := []string{"rsa-sha2-256"}
srvCfg := &serverConfig{
cfg: &config.Config{
Server: config.ServerConfig{
MACs: customMACs,
KexAlgorithms: customKexAlgos,
Ciphers: customCiphers,
MACs: customMACs,
KexAlgorithms: customKexAlgos,
Ciphers: customCiphers,
PublicKeyAlgorithms: customPublicKeyAlgorithms,
},
},
}
Loading
Loading
@@ -288,6 +291,7 @@ func TestCustomAlgorithms(t *testing.T) {
require.Equal(t, customMACs, sshServerConfig.MACs)
require.Equal(t, customKexAlgos, sshServerConfig.KeyExchanges)
require.Equal(t, customCiphers, sshServerConfig.Ciphers)
require.Equal(t, customPublicKeyAlgorithms, sshServerConfig.PublicKeyAuthAlgorithms)
sshServerConfig.SetDefaults()
Loading
Loading
Loading
Loading
@@ -110,7 +110,15 @@ func (s *Server) listen(ctx context.Context) error {
log.ContextLogger(ctx).Info("Proxy protocol is enabled")
}
log.WithContextFields(ctx, log.Fields{"tcp_address": sshListener.Addr().String()}).Info("Listening for SSH connections")
fields := log.Fields{
"tcp_address": sshListener.Addr().String(),
}
if len(s.serverConfig.cfg.Server.PublicKeyAlgorithms) > 0 {
fields["supported_public_key_algorithms"] = s.serverConfig.cfg.Server.PublicKeyAlgorithms
}
log.WithContextFields(ctx, fields).Info("Listening for SSH connections")
s.listener = sshListener
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment