Make SSH_PORT configurable
This commit is contained in:
parent
2bcd70c1ec
commit
4752c0fcec
9 changed files with 25 additions and 7 deletions
|
|
@ -68,6 +68,9 @@ type Config struct {
|
|||
// This variable can be used to determine their length.
|
||||
PasswordLength int `env:"PASSWORD_LENGTH" default:"64" parser:"number"`
|
||||
|
||||
// Public port to use for the ssh server
|
||||
PublicSSHPort uint16 `env:"SSH_PORT" default:"2222" parser:"port"`
|
||||
|
||||
// A file to be used for global authorized_keys for the ssh server.
|
||||
GlobalAuthorizedKeysFile string `env:"GLOBAL_AUTHORIZED_KEYS_FILE" default:"/var/www/deploy/authorized_keys" parser:"file"`
|
||||
|
||||
|
|
|
|||
|
|
@ -58,6 +58,9 @@ PASSWORD_LENGTH=64
|
|||
# A file to be used for global authorized_keys for the ssh server.
|
||||
GLOBAL_AUTHORIZED_KEYS_FILE=${AUTHORIZED_KEYS_FILE}
|
||||
|
||||
# the port to use for the ssh server
|
||||
SSH_PORT=2222
|
||||
|
||||
# The admin user and password of the GraphDB interface, to be used for queries
|
||||
GRAPHDB_ADMIN_USER=${GRAPHDB_ADMIN_USER}
|
||||
GRAPHDB_ADMIN_PASSWORD=${GRAPHDB_ADMIN_PASSWORD}
|
||||
|
|
|
|||
|
|
@ -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])
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
||||
//
|
||||
|
|
|
|||
|
|
@ -8,3 +8,4 @@ SELF_RESOLVER_BLOCK_FILE=${SELF_RESOLVER_BLOCK_FILE}
|
|||
|
||||
DOCKER_NETWORK_NAME=${DOCKER_NETWORK_NAME}
|
||||
HTTPS_ENABLED=${HTTPS_ENABLED}
|
||||
SSH_PORT=${SSH_PORT}
|
||||
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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},
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@ var knownParsers map[string]Parser[any] = map[string]Parser[any]{
|
|||
"domain": asGenericParser(ParseValidDomain),
|
||||
"domains": asGenericParser(ParseValidDomains),
|
||||
"number": asGenericParser(ParseNumber),
|
||||
"port": asGenericParser(ParsePort),
|
||||
"https_url": asGenericParser(ParseHttpsURL),
|
||||
"slug": asGenericParser(ParseSlug),
|
||||
"file": asGenericParser(ParseFile),
|
||||
|
|
|
|||
|
|
@ -76,6 +76,12 @@ func ParseNumber(env environment.Environment, s string) (int, error) {
|
|||
return int(value), err
|
||||
}
|
||||
|
||||
// ParsePort parses s as a port
|
||||
func ParsePort(env environment.Environment, s string) (uint16, error) {
|
||||
value, err := strconv.ParseUint(s, 10, 16)
|
||||
return uint16(value), err
|
||||
}
|
||||
|
||||
// ParseHttpsURL parses a string into a url that starts with 'https://'
|
||||
func ParseHttpsURL(env environment.Environment, s string) (*url.URL, error) {
|
||||
url, err := url.Parse(s)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue