Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

podman machine init fails if ~/.ssh/ doesn't exist #14572

Closed
aslilac opened this issue Jun 11, 2022 · 1 comment · Fixed by #14952
Closed

podman machine init fails if ~/.ssh/ doesn't exist #14572

aslilac opened this issue Jun 11, 2022 · 1 comment · Fixed by #14952
Assignees
Labels
kind/bug Categorizes issue or PR as related to a bug. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. machine remote Problem is in podman-remote ssh

Comments

@aslilac
Copy link

aslilac commented Jun 11, 2022

Is this a BUG REPORT or FEATURE REQUEST? (leave only one on its own line)

/kind bug

Description

Running podman machine init in a context where the HOME directory doesn't contain a .ssh/ folder will cause it to error out without providing any meaningful error output.

The chain of events appears to be...

  • pkg/machine/qemu/machine.go:379: we call machine.GenerateSSHKeys
  • pkg/machine/keys.go:23: we call generatekeys
  • pkg/machine/keys.go:56: we run something like ssh-keygen -N "" -t ... -f $HOME/.ssh/...

At least on macOS, that call to ssh-keygen will fail if ~/.ssh/ doesn't exist. The error then gets propagated up until eventually the program exists without ever printing anything useful along the way.

I clearly spent a lot of time debugging this 😅 I'd put up a PR to fix it but I don't really get how error handling in Go works, and I'm not sure what the "right way" to go about it would be. Hopefully I've at least provided enough detail that it'll be easy for someone else to fix.

Steps to reproduce the issue:

  1. Set HOME env var to a directory which does not contain a .ssh/ folder

  2. Run podman machine init

Describe the results you received:

Error output just says...

Error code: 1

...which is super unhelpful

Describe the results you expected:

Should probably just assert that the directory exists before calling machine.GenerateSSHKeys

Additional information you deem important (e.g. issue happens only occasionally):

Output of podman version:

podman version 4.1.0

Output of podman info --debug:

host:
  arch: arm64
  buildahVersion: 1.26.1
  cgroupControllers:
  - cpu
  - io
  - memory
  - pids
  cgroupManager: systemd
  cgroupVersion: v2
  conmon:
    package: conmon-2.1.0-2.fc36.aarch64
    path: /usr/bin/conmon
    version: 'conmon version 2.1.0, commit: '
  cpuUtilization:
    idlePercent: 99.88
    systemPercent: 0.09
    userPercent: 0.03
  cpus: 1
  distribution:
    distribution: fedora
    variant: coreos
    version: "36"
  eventLogger: journald
  hostname: localhost.localdomain
  idMappings:
    gidmap:
    - container_id: 0
      host_id: 1000
      size: 1
    - container_id: 1
      host_id: 100000
      size: 1000000
    uidmap:
    - container_id: 0
      host_id: 501
      size: 1
    - container_id: 1
      host_id: 100000
      size: 1000000
  kernel: 5.17.5-300.fc36.aarch64
  linkmode: dynamic
  logDriver: journald
  memFree: 1612713984
  memTotal: 2053337088
  networkBackend: netavark
  ociRuntime:
    name: crun
    package: crun-1.4.4-1.fc36.aarch64
    path: /usr/bin/crun
    version: |-
      crun version 1.4.4
      commit: 6521fcc5806f20f6187eb933f9f45130c86da230
      spec: 1.0.0
      +SYSTEMD +SELINUX +APPARMOR +CAP +SECCOMP +EBPF +CRIU +YAJL
  os: linux
  remoteSocket:
    exists: true
    path: /run/user/501/podman/podman.sock
  security:
    apparmorEnabled: false
    capabilities: CAP_CHOWN,CAP_DAC_OVERRIDE,CAP_FOWNER,CAP_FSETID,CAP_KILL,CAP_NET_BIND_SERVICE,CAP_SETFCAP,CAP_SETGID,CAP_SETPCAP,CAP_SETUID,CAP_SYS_CHROOT
    rootless: true
    seccompEnabled: true
    seccompProfilePath: /usr/share/containers/seccomp.json
    selinuxEnabled: true
  serviceIsRemote: true
  slirp4netns:
    executable: /usr/bin/slirp4netns
    package: slirp4netns-1.2.0-0.2.beta.0.fc36.aarch64
    version: |-
      slirp4netns version 1.2.0-beta.0
      commit: 477db14a24ff1a3de3a705e51ca2c4c1fe3dda64
      libslirp: 4.6.1
      SLIRP_CONFIG_VERSION_MAX: 3
      libseccomp: 2.5.3
  swapFree: 0
  swapTotal: 0
  uptime: 31h 3m 58.27s (Approximately 1.29 days)
plugins:
  log:
  - k8s-file
  - none
  - passthrough
  - journald
  network:
  - bridge
  - macvlan
  volume:
  - local
registries:
  search:
  - docker.io
store:
  configFile: /var/home/core/.config/containers/storage.conf
  containerStore:
    number: 8
    paused: 0
    running: 1
    stopped: 7
  graphDriverName: overlay
  graphOptions: {}
  graphRoot: /var/home/core/.local/share/containers/storage
  graphRootAllocated: 106825756672
  graphRootUsed: 7253413888
  graphStatus:
    Backing Filesystem: xfs
    Native Overlay Diff: "true"
    Supports d_type: "true"
    Using metacopy: "false"
  imageCopyTmpDir: /var/tmp
  imageStore:
    number: 12
  runRoot: /run/user/501/containers
  volumePath: /var/home/core/.local/share/containers/storage/volumes
version:
  APIVersion: 4.1.0
  Built: 1651853798
  BuiltTime: Fri May  6 10:16:38 2022
  GitCommit: ""
  GoVersion: go1.18
  Os: linux
  OsArch: linux/arm64
  Version: 4.1.0

Package info (e.g. output of rpm -q podman or apt list podman):

N/A, on macOS, installed through brew

Have you tested with the latest version of Podman and have you checked the Podman Troubleshooting Guide? (https://github.com/containers/podman/blob/main/troubleshooting.md)

Yes/No

Additional environment details (AWS, VirtualBox, physical, etc.):

@openshift-ci openshift-ci bot added the kind/bug Categorizes issue or PR as related to a bug. label Jun 11, 2022
@github-actions github-actions bot added the remote Problem is in podman-remote label Jun 11, 2022
@vrothberg
Copy link
Member

Thanks for reaching out, @aslilac!

@ashley-cui PTAL

@ashley-cui ashley-cui self-assigned this Jun 13, 2022
@Luap99 Luap99 added the machine label Jun 14, 2022
@rhatdan rhatdan added the ssh label Jun 22, 2022
@github-actions github-actions bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Sep 20, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 20, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/bug Categorizes issue or PR as related to a bug. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. machine remote Problem is in podman-remote ssh
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants