Make SSH_PORT configurable

This commit is contained in:
Tom Wiesing 2022-11-17 09:43:01 +01:00
parent 2bcd70c1ec
commit 4752c0fcec
No known key found for this signature in database
9 changed files with 25 additions and 7 deletions

View file

@ -3,6 +3,7 @@ package ssh2
import (
"bufio"
"io"
"strconv"
"strings"
"github.com/gliderlabs/ssh"
@ -34,7 +35,7 @@ is the name of the WissKI you want to you want to connect to.
From a linux (or mac, or windows 11) command line you may use:
ssh -J ${DOMAIN}:2222 www-data@${HOSTNAME}
ssh -J ${DOMAIN}:${PORT} www-data@${HOSTNAME}
You may also place the following into your $HOME/.ssh/config file:
@ -44,7 +45,7 @@ Host *.${DOMAIN}
Host ${DOMAIN}.proxy
User www-data
Hostname ${DOMAIN}
Port 2222
Port ${PORT}
and then connect simply via:
@ -81,6 +82,7 @@ func (ssh2 *SSH2) handleConnection(session ssh.Session) {
{"${SLUG}", slug},
{"${DOMAIN}", ssh2.Config.DefaultDomain},
{"${HOSTNAME}", slug + "." + ssh2.Config.DefaultDomain},
{"${PORT}", strconv.FormatUint(uint64(ssh2.Config.PublicSSHPort), 10)},
} {
banner = strings.ReplaceAll(banner, oldnew[0], oldnew[1])
}

View file

@ -118,10 +118,10 @@ func (ssh2 *SSH2) makeHostKey(io stream.IOStream, key HostKey, path string) erro
// generate and write private key as PEM
privateKeyFile, err := ssh2.Environment.Create(path, environment.DefaultFilePerm)
defer privateKeyFile.Close()
if err != nil {
return err
}
defer privateKeyFile.Close()
return pem.Encode(privateKeyFile, privateKeyPEM)
}
@ -228,8 +228,7 @@ func (ek *ed25519HostKey) UnmarshalPEM(block *pem.Block) (err error) {
// store the private key and setup the signer
ek.pk = &pk
ek.Signer, err = gossh.NewSignerFromKey(ek.pk)
return nil
return err
}
//

View file

@ -7,4 +7,5 @@ SELF_OVERRIDES_FILE=${SELF_OVERRIDES_FILE}
SELF_RESOLVER_BLOCK_FILE=${SELF_RESOLVER_BLOCK_FILE}
DOCKER_NETWORK_NAME=${DOCKER_NETWORK_NAME}
HTTPS_ENABLED=${HTTPS_ENABLED}
HTTPS_ENABLED=${HTTPS_ENABLED}
SSH_PORT=${SSH_PORT}

View file

@ -7,7 +7,7 @@ services:
environment:
CONFIG_PATH: ${CONFIG_PATH}
ports:
- "2222:2222"
- "${SSH_PORT}:2222"
volumes:
- "/var/run/docker.sock:/var/run/docker.sock"
- "${CONFIG_PATH}:${CONFIG_PATH}:ro"

View file

@ -3,6 +3,7 @@ package ssh2
import (
"embed"
"path/filepath"
"strconv"
"github.com/FAU-CDI/wisski-distillery/internal/bootstrap"
"github.com/FAU-CDI/wisski-distillery/internal/dis/component"
@ -33,6 +34,8 @@ func (ssh *SSH2) Stack(env environment.Environment) component.StackWithResources
"GLOBAL_AUTHORIZED_KEYS_FILE": ssh.Config.GlobalAuthorizedKeysFile,
"SELF_OVERRIDES_FILE": ssh.Config.SelfOverridesFile,
"SELF_RESOLVER_BLOCK_FILE": ssh.Config.SelfResolverBlockFile,
"SSH_PORT": strconv.FormatUint(uint64(ssh.Config.PublicSSHPort), 10),
},
CopyContextFiles: []string{bootstrap.Executable},