diff options
author | zeripath <art27@cantab.net> | 2021-03-08 02:43:59 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-08 03:43:59 +0100 |
commit | c03f530212249b18ffb73dfa47c99e9a4ed7c86c (patch) | |
tree | d6fc58f469c32e796491eee02a1f9ccbfde957ae /modules/setting | |
parent | 78b7529cd471eafefd555fe82b8dbb8b63dcd9f5 (diff) | |
download | gitea-c03f530212249b18ffb73dfa47c99e9a4ed7c86c.tar.gz gitea-c03f530212249b18ffb73dfa47c99e9a4ed7c86c.zip |
Make internal SSH server host key path configurable (#14918)
* Make SSH server host key path configurable
* make it possible to have multiple keys
* Make gitea.rsa the default key
* Add some more logging
Signed-off-by: Andrew Thornton <art27@cantab.net>
Diffstat (limited to 'modules/setting')
-rw-r--r-- | modules/setting/setting.go | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/modules/setting/setting.go b/modules/setting/setting.go index 4976c0007c..60e433b1a2 100644 --- a/modules/setting/setting.go +++ b/modules/setting/setting.go @@ -132,6 +132,7 @@ var ( ServerCiphers []string `ini:"SSH_SERVER_CIPHERS"` ServerKeyExchanges []string `ini:"SSH_SERVER_KEY_EXCHANGES"` ServerMACs []string `ini:"SSH_SERVER_MACS"` + ServerHostKeys []string `ini:"SSH_SERVER_HOST_KEYS"` KeyTestPath string `ini:"SSH_KEY_TEST_PATH"` KeygenPath string `ini:"SSH_KEYGEN_PATH"` AuthorizedKeysBackup bool `ini:"SSH_AUTHORIZED_KEYS_BACKUP"` @@ -157,6 +158,7 @@ var ( KeygenPath: "ssh-keygen", MinimumKeySizeCheck: true, MinimumKeySizes: map[string]int{"ed25519": 256, "ed25519-sk": 256, "ecdsa": 256, "ecdsa-sk": 256, "rsa": 2048}, + ServerHostKeys: []string{"ssh/gitea.rsa", "ssh/gogs.rsa"}, } // Security settings @@ -698,6 +700,11 @@ func NewContext() { if err = Cfg.Section("server").MapTo(&SSH); err != nil { log.Fatal("Failed to map SSH settings: %v", err) } + for i, key := range SSH.ServerHostKeys { + if !filepath.IsAbs(key) { + SSH.ServerHostKeys[i] = filepath.Join(AppDataPath, key) + } + } SSH.KeygenPath = sec.Key("SSH_KEYGEN_PATH").MustString("ssh-keygen") SSH.Port = sec.Key("SSH_PORT").MustInt(22) |