internal/dis/component/ssh: Shorten help text

This commit is contained in:
Tom Wiesing 2023-03-15 11:26:03 +01:00
parent ed00ef7aff
commit 0c888eab1c
No known key found for this signature in database
2 changed files with 22 additions and 41 deletions

View file

@ -2,6 +2,7 @@ package config
import ( import (
"fmt" "fmt"
"net/url"
"strings" "strings"
"github.com/tkw1536/pkglib/collection" "github.com/tkw1536/pkglib/collection"
@ -23,6 +24,20 @@ type HTTPConfig struct {
CertbotEmail string `yaml:"certbot_email" validate:"email"` CertbotEmail string `yaml:"certbot_email" validate:"email"`
} }
// JoinPath returns the root public url joined with the provided parts.
func (hcfg HTTPConfig) JoinPath(elem ...string) *url.URL {
u := url.URL{
Scheme: "http",
Host: hcfg.PrimaryDomain,
Path: "/",
}
if hcfg.HTTPSEnabled() {
u.Scheme = "https"
}
return u.JoinPath(elem...)
}
// TCPMuxCommand generates a command line for the sslh executable. // TCPMuxCommand generates a command line for the sslh executable.
func (hcfg HTTPConfig) TCPMuxCommand(addr string, http string, https string, ssh string) string { func (hcfg HTTPConfig) TCPMuxCommand(addr string, http string, https string, ssh string) string {
if hcfg.HTTPSEnabled() { if hcfg.HTTPSEnabled() {

View file

@ -26,50 +26,13 @@ You've successfully authenticated, but we don't provide shell access to
the main server. You may use this connection as part of a proxy jump to the main server. You may use this connection as part of a proxy jump to
connect to your WissKI Instance. connect to your WissKI Instance.
In the following we will provide instructions on how to connect to your To connect to a WissKI named ${SLUG} you may use:
distillery instance via this server. We will assume
${SLUG}
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}:${PORT} www-data@${HOSTNAME} ssh -J ${DOMAIN}:${PORT} www-data@${HOSTNAME}
You may also place the following into your $HOME/.ssh/config file: For more details see:
Host *.${DOMAIN} ${HELP_URL}
ProxyJump ${DOMAIN}.proxy
User www-data
Host ${DOMAIN}.proxy
User www-data
Hostname ${DOMAIN}
Port ${PORT}
and then connect simply via:
ssh ${HOSTNAME}
On windows you should use the "ssh" executable from the command line if
available.
If you must, you can also use Putty.
THIS IS NOT RECOMMENDED AND NOT OFFICIALLY SUPPORTED
First make sure your SSH Key is configured under Connection > Auth >
Credentials. Then configure a proxy under Connection > Proxy. The Proxy
Hostname should be
${DOMAIN}
and the port "${PORT}". The proxy type should be "SSH to proxy and use
port forwarding". Then you may enter the hostname
www-data@${HOSTNAME}
with port 22.
Press CTRL-C to close this connection. Press CTRL-C to close this connection.
` `
@ -80,9 +43,12 @@ func (ssh2 *SSH2) handleConnection(session ssh.Session) {
banner := welcomeMessage banner := welcomeMessage
for _, oldnew := range [][2]string{ for _, oldnew := range [][2]string{
{"${SLUG}", slug}, {"${SLUG}", slug},
{"${DOMAIN}", ssh2.Config.HTTP.PrimaryDomain},
{"${HOSTNAME}", slug + "." + ssh2.Config.HTTP.PrimaryDomain}, {"${HOSTNAME}", slug + "." + ssh2.Config.HTTP.PrimaryDomain},
{"${DOMAIN}", ssh2.Config.HTTP.PrimaryDomain},
{"${PORT}", strconv.FormatUint(uint64(ssh2.Config.Listen.SSHPort), 10)}, {"${PORT}", strconv.FormatUint(uint64(ssh2.Config.Listen.SSHPort), 10)},
{"${HELP_URL}", ssh2.Config.HTTP.JoinPath("user", "ssh").String()},
} { } {
banner = strings.ReplaceAll(banner, oldnew[0], oldnew[1]) banner = strings.ReplaceAll(banner, oldnew[0], oldnew[1])
} }