MCPcopy Create free account
hub / github.com/devnullvoid/pvetui / resolveVMSSHUser

Method resolveVMSSHUser

internal/cli/cli_helpers.go:463–483  ·  view source on GitHub ↗

resolveVMSSHUser returns the SSH username to use when connecting directly to a QEMU VM, falling back to the host SSH user if vm_ssh_user is not set.

(vm *api.VM)

Source from the content-addressed store, hash-verified

461// resolveVMSSHUser returns the SSH username to use when connecting directly to
462// a QEMU VM, falling back to the host SSH user if vm_ssh_user is not set.
463func (s *cliSession) resolveVMSSHUser(vm *api.VM) string {
464 var vmSSHUser string
465
466 if vm != nil && vm.SourceProfile != "" {
467 if p, ok := s.cfg.Profiles[vm.SourceProfile]; ok && p.VMSSHUser != "" {
468 vmSSHUser = p.VMSSHUser
469 }
470 }
471
472 if vmSSHUser == "" {
473 vmSSHUser = s.cfg.VMSSHUser
474 }
475
476 if vmSSHUser == "" {
477 // Fall back to host SSH user.
478 hostUser, _, _ := s.resolveSSHCreds(vm)
479 vmSSHUser = hostUser
480 }
481
482 return vmSSHUser
483}
484
485// resolveVMSSHKeyfile returns the SSH keyfile to use when connecting directly
486// to a QEMU VM. Prefers vm_ssh_keyfile, falls back to ssh_keyfile.

Callers 1

runQEMUShellFunction · 0.80

Calls 1

resolveSSHCredsMethod · 0.95

Tested by

no test coverage detected