orchard controller run: introduce --insecure-ssh-no-client-auth (#187)
This commit is contained in:
parent
ff0497b1d8
commit
8119b22817
|
|
@ -19,6 +19,7 @@ var BootstrapAdminAccountName = "bootstrap-admin"
|
|||
var address string
|
||||
var addressSSH string
|
||||
var debug bool
|
||||
var sshNoClientAuth bool
|
||||
|
||||
func newRunCommand() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
|
|
@ -48,6 +49,9 @@ func newRunCommand() *cobra.Command {
|
|||
" (requires --controller-cert)")
|
||||
cmd.PersistentFlags().StringVar(&sshHostKeyPath, "ssh-host-key", "",
|
||||
"use the SSH private host key from the specified path instead of the auto-generated one")
|
||||
cmd.PersistentFlags().BoolVar(&sshNoClientAuth, "insecure-ssh-no-client-auth", false,
|
||||
"allow SSH clients to connect to the controller's SSH server without authentication, "+
|
||||
"thus only authenticating on the target worker/VM's SSH server")
|
||||
|
||||
return cmd
|
||||
}
|
||||
|
|
@ -103,7 +107,7 @@ func runController(cmd *cobra.Command, args []string) (err error) {
|
|||
return err
|
||||
}
|
||||
|
||||
controllerOpts = append(controllerOpts, controller.WithSSHServer(addressSSH, signer))
|
||||
controllerOpts = append(controllerOpts, controller.WithSSHServer(addressSSH, signer, sshNoClientAuth))
|
||||
}
|
||||
|
||||
controllerInstance, err := controller.New(controllerOpts...)
|
||||
|
|
|
|||
|
|
@ -59,9 +59,10 @@ type Controller struct {
|
|||
workerOfflineTimeout time.Duration
|
||||
maxWorkersPerLicense uint
|
||||
|
||||
sshListenAddr string
|
||||
sshSigner ssh.Signer
|
||||
sshServer *sshserver.SSHServer
|
||||
sshListenAddr string
|
||||
sshSigner ssh.Signer
|
||||
sshNoClientAuth bool
|
||||
sshServer *sshserver.SSHServer
|
||||
|
||||
rpc.UnimplementedControllerServer
|
||||
}
|
||||
|
|
@ -124,7 +125,7 @@ func New(opts ...Option) (*Controller, error) {
|
|||
// Instantiate the SSH server (if configured)
|
||||
if controller.sshListenAddr != "" && controller.sshSigner != nil {
|
||||
controller.sshServer, err = sshserver.NewSSHServer(controller.sshListenAddr, controller.sshSigner,
|
||||
store, controller.proxy, controller.workerNotifier, controller.logger)
|
||||
store, controller.proxy, controller.workerNotifier, controller.sshNoClientAuth, controller.logger)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,10 +27,11 @@ func WithTLSConfig(tlsConfig *tls.Config) Option {
|
|||
}
|
||||
}
|
||||
|
||||
func WithSSHServer(listenAddr string, signer ssh.Signer) Option {
|
||||
func WithSSHServer(listenAddr string, signer ssh.Signer, noClientAuth bool) Option {
|
||||
return func(controller *Controller) {
|
||||
controller.sshListenAddr = listenAddr
|
||||
controller.sshSigner = signer
|
||||
controller.sshNoClientAuth = noClientAuth
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ func NewSSHServer(
|
|||
store storepkg.Store,
|
||||
proxy *proxypkg.Proxy,
|
||||
workerNotifier *notifier.Notifier,
|
||||
noClientAuth bool,
|
||||
logger *zap.SugaredLogger,
|
||||
) (*SSHServer, error) {
|
||||
server := &SSHServer{
|
||||
|
|
@ -58,6 +59,7 @@ func NewSSHServer(
|
|||
server.listener = listener
|
||||
|
||||
server.serverConfig = &ssh.ServerConfig{
|
||||
NoClientAuth: noClientAuth,
|
||||
PasswordCallback: server.passwordCallback,
|
||||
}
|
||||
server.serverConfig.AddHostKey(signer)
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ func TestSSHServer(t *testing.T) {
|
|||
|
||||
// Run the Controller
|
||||
devClient, devController, _ := devcontroller.StartIntegrationTestEnvironmentWithAdditionalOpts(t, []controller.Option{
|
||||
controller.WithSSHServer(":0", signer),
|
||||
controller.WithSSHServer(":0", signer, false),
|
||||
}, nil)
|
||||
|
||||
// Create a VM to which we'll connect via Controller's SSH server
|
||||
|
|
|
|||
Loading…
Reference in New Issue