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

Method resolveSSHCreds

internal/cli/cli_helpers.go:355–381  ·  view source on GitHub ↗

resolveSSHCreds returns the SSH username, keyfile path, and jump-host config to use for the node that hosts vm, preferring the guest's source profile when available.

(vm *api.VM)

Source from the content-addressed store, hash-verified

353// resolveSSHCreds returns the SSH username, keyfile path, and jump-host config
354// to use for the node that hosts vm, preferring the guest's source profile when available.
355func (s *cliSession) resolveSSHCreds(vm *api.VM) (sshUser string, sshKeyfile string, jumpHost config.SSHJumpHost) {
356 if vm != nil && vm.SourceProfile != "" {
357 if p, ok := s.cfg.Profiles[vm.SourceProfile]; ok {
358 if p.SSHUser != "" {
359 sshUser = p.SSHUser
360 }
361 if p.SSHKeyfile != "" {
362 sshKeyfile = p.SSHKeyfile
363 }
364 if p.SSHJumpHost.Addr != "" {
365 jumpHost = p.SSHJumpHost
366 }
367 }
368 }
369
370 if sshUser == "" {
371 sshUser = s.cfg.SSHUser
372 }
373 if sshKeyfile == "" {
374 sshKeyfile = s.cfg.SSHKeyfile
375 }
376 if jumpHost.Addr == "" {
377 jumpHost = s.cfg.SSHJumpHost
378 }
379
380 return sshUser, sshKeyfile, jumpHost
381}
382
383// execLXC executes cmdParts inside an LXC container via SSH to its host node
384// using pct exec. Returns stdout, stderr, exit code, and any transport error.

Callers 2

execLXCMethod · 0.95
resolveVMSSHUserMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected