From 29722af1ae51333a7da742b5e02a5e7fe5983aab Mon Sep 17 00:00:00 2001 From: spacetourist Date: Fri, 10 Feb 2017 19:04:43 +0000 Subject: Configurable SSH cipher suite (#4109) * Configurable SSH cipher suite * Maintain ordering --- modules/setting/setting.go | 2 ++ modules/ssh/ssh.go | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/setting/setting.go b/modules/setting/setting.go index b5c6d9c9..4db8dbff 100644 --- a/modules/setting/setting.go +++ b/modules/setting/setting.go @@ -85,6 +85,7 @@ var ( ListenHost string `ini:"SSH_LISTEN_HOST"` ListenPort int `ini:"SSH_LISTEN_PORT"` RootPath string `ini:"SSH_ROOT_PATH"` + ServerCiphers []string `ini:"SSH_SERVER_CIPHERS"` KeyTestPath string `ini:"SSH_KEY_TEST_PATH"` KeygenPath string `ini:"SSH_KEYGEN_PATH"` MinimumKeySizeCheck bool `ini:"-"` @@ -425,6 +426,7 @@ func NewContext() { } SSH.RootPath = path.Join(homeDir, ".ssh") + SSH.ServerCiphers = sec.Key("SSH_SERVER_CIPHERS").Strings(",") SSH.KeyTestPath = os.TempDir() if err = Cfg.Section("server").MapTo(&SSH); err != nil { log.Fatal(4, "Fail to map SSH settings: %v", err) diff --git a/modules/ssh/ssh.go b/modules/ssh/ssh.go index 025d4b57..bdb58469 100644 --- a/modules/ssh/ssh.go +++ b/modules/ssh/ssh.go @@ -148,8 +148,11 @@ func listen(config *ssh.ServerConfig, host string, port int) { } // Listen starts a SSH server listens on given port. -func Listen(host string, port int) { +func Listen(host string, port int, ciphers []string) { config := &ssh.ServerConfig{ + Config: ssh.Config{ + Ciphers: ciphers, + }, PublicKeyCallback: func(conn ssh.ConnMetadata, key ssh.PublicKey) (*ssh.Permissions, error) { pkey, err := models.SearchPublicKeyByContent(strings.TrimSpace(string(ssh.MarshalAuthorizedKey(key)))) if err != nil { -- cgit v1.2.3