ssh: Update welcome message
This commit is contained in:
parent
8cfb23bed0
commit
7bfcfb3510
2 changed files with 71 additions and 12 deletions
|
|
@ -12,16 +12,6 @@ const (
|
||||||
eot rune = 4
|
eot rune = 4
|
||||||
)
|
)
|
||||||
|
|
||||||
const welcomeMessage = `Welcome to the WissKI SSH Server.
|
|
||||||
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 connect to your server.
|
|
||||||
For example:
|
|
||||||
|
|
||||||
ssh -J %s:2222 www-data@%s
|
|
||||||
|
|
||||||
Press CTRL-C to close this connection.
|
|
||||||
`
|
|
||||||
|
|
||||||
// Server returns an ssh server that implements the main ssh server
|
// Server returns an ssh server that implements the main ssh server
|
||||||
func (ssh2 *SSH2) Server(context context.Context, privateKeyPath string, io stream.IOStream) (*ssh.Server, error) {
|
func (ssh2 *SSH2) Server(context context.Context, privateKeyPath string, io stream.IOStream) (*ssh.Server, error) {
|
||||||
var server ssh.Server
|
var server ssh.Server
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,8 @@ package ssh2
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"fmt"
|
|
||||||
"io"
|
"io"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/gliderlabs/ssh"
|
"github.com/gliderlabs/ssh"
|
||||||
)
|
)
|
||||||
|
|
@ -12,9 +12,78 @@ func (ssh2 *SSH2) setupHandler(server *ssh.Server) {
|
||||||
server.Handle(ssh2.handleConnection)
|
server.Handle(ssh2.handleConnection)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const welcomeMessage = `
|
||||||
|
__ ___ _ _____ ____ _ _ _ _ _
|
||||||
|
\ \ / (_)___ ___| |/ /_ _| | _ \(_)___| |_(_) | | ___ _ __ _ _
|
||||||
|
\ \ /\ / /| / __/ __| ' / | | | | | | / __| __| | | |/ _ \ '__| | | |
|
||||||
|
\ V V / | \__ \__ \ . \ | | | |_| | \__ \ |_| | | | __/ | | |_| |
|
||||||
|
\_/\_/ |_|___/___/_|\_\___| |____/|_|___/\__|_|_|_|\___|_| \__, |
|
||||||
|
|___/
|
||||||
|
|
||||||
|
Welcome to the WissKI SSH Server.
|
||||||
|
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
|
||||||
|
connect to your WissKI Instance.
|
||||||
|
|
||||||
|
In the following we will provide instructions on how to connect to your
|
||||||
|
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}:2222 www-data@${HOSTNAME}
|
||||||
|
|
||||||
|
You may also place the following into your $HOME/.ssh/config file:
|
||||||
|
|
||||||
|
Host *.${DOMAIN}
|
||||||
|
ProxyJump ${DOMAIN}.proxy
|
||||||
|
User www-data
|
||||||
|
Host ${DOMAIN}.proxy
|
||||||
|
User www-data
|
||||||
|
Hostname ${DOMAIN}
|
||||||
|
Port 2222
|
||||||
|
|
||||||
|
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 "2222". 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.
|
||||||
|
`
|
||||||
|
|
||||||
func (ssh2 *SSH2) handleConnection(session ssh.Session) {
|
func (ssh2 *SSH2) handleConnection(session ssh.Session) {
|
||||||
slug, _ := getAnyPermission(session.Context())
|
slug, _ := getAnyPermission(session.Context())
|
||||||
banner := fmt.Sprintf(welcomeMessage, ssh2.Config.DefaultDomain, slug+"."+ssh2.Config.DefaultDomain)
|
|
||||||
|
banner := welcomeMessage
|
||||||
|
for _, oldnew := range [][2]string{
|
||||||
|
{"${SLUG}", slug},
|
||||||
|
{"${DOMAIN}", ssh2.Config.DefaultDomain},
|
||||||
|
{"${HOSTNAME}", slug + "." + ssh2.Config.DefaultDomain},
|
||||||
|
} {
|
||||||
|
banner = strings.ReplaceAll(banner, oldnew[0], oldnew[1])
|
||||||
|
}
|
||||||
|
|
||||||
io.WriteString(session, banner)
|
io.WriteString(session, banner)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue