mirror of
https://github.com/moul/sshportal.git
synced 2025-01-10 01:18:19 +08:00
30 lines
642 B
Go
30 lines
642 B
Go
|
package main
|
||
|
|
||
|
import (
|
||
|
"os"
|
||
|
|
||
|
"github.com/gliderlabs/ssh"
|
||
|
gossh "golang.org/x/crypto/ssh"
|
||
|
)
|
||
|
|
||
|
type Config struct {
|
||
|
clientConfig *gossh.ClientConfig
|
||
|
remoteAddr string
|
||
|
}
|
||
|
|
||
|
func getConfig(s ssh.Session) (*Config, error) {
|
||
|
// TODO: get the config from a database
|
||
|
config := Config{
|
||
|
remoteAddr: os.Getenv("SSH_ADDR"),
|
||
|
clientConfig: &gossh.ClientConfig{
|
||
|
User: os.Getenv("SSH_USERNAME"),
|
||
|
HostKeyCallback: gossh.InsecureIgnoreHostKey(), // TODO: show the remote host to the client + store it in db if approved
|
||
|
Auth: []gossh.AuthMethod{
|
||
|
gossh.Password(os.Getenv("SSH_PASSWORD")),
|
||
|
},
|
||
|
},
|
||
|
}
|
||
|
|
||
|
return &config, nil
|
||
|
}
|