orchard controller run: introduce --insecure-ssh-no-client-auth (#187)

This commit is contained in:
Nikolay Edigaryev 2024-06-28 23:55:18 +04:00 committed by GitHub
parent ff0497b1d8
commit 8119b22817
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 15 additions and 7 deletions

View File

@ -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...)

View File

@ -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
}

View File

@ -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
}
}

View File

@ -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)

View File

@ -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