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)
| 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. |
| 463 | func (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. |
no test coverage detected