2015-01-02 15:51:37 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"golang.org/x/crypto/ssh"
|
2015-01-02 17:01:52 +00:00
|
|
|
"runtime"
|
2015-01-02 15:51:37 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
|
2015-01-02 17:01:52 +00:00
|
|
|
// Allow Go to use all CPUs:
|
|
|
|
runtime.GOMAXPROCS(runtime.NumCPU())
|
|
|
|
|
|
|
|
// Read the configuration from the command-line args:
|
2015-01-02 15:51:37 +00:00
|
|
|
readFlags()
|
2015-01-02 17:01:52 +00:00
|
|
|
|
|
|
|
// Create the SSH configuration:
|
2015-01-02 15:51:37 +00:00
|
|
|
config := &ssh.ClientConfig{
|
|
|
|
User: username,
|
|
|
|
Auth: []ssh.AuthMethod{
|
|
|
|
ssh.Password(password),
|
|
|
|
ssh.PasswordCallback(passwordCallback),
|
|
|
|
ssh.KeyboardInteractive(keyboardInteractiveChallenge),
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2015-01-02 17:01:52 +00:00
|
|
|
// Create the local end-point:
|
|
|
|
localListener := createLocalEndPoint()
|
2015-01-02 15:51:37 +00:00
|
|
|
|
2015-01-02 17:01:52 +00:00
|
|
|
// Accept client connections (will block forever):
|
|
|
|
acceptClients(localListener, config)
|
2015-01-02 15:51:37 +00:00
|
|
|
}
|