system connection add --ssh native fails rootless: ssh runs inside the user namespace and reads /root/.ssh
Issue Description
Running rootless, podman --ssh native system connection add fails with only Error: exit status 255. Plain ssh to the same host works.
The command runs inside the rootless user namespace, where the ssh it spawns sees uid 0. ssh then looks up its home from the passwd entry for uid 0, so it reads /root/.ssh/known_hosts and /root/.ssh keys instead of the user's. It can't verify the host key and exits 255. Podman also throws away ssh's stderr, so the real reason never reaches the user.
podman compose and podman image scp avoid this with registry.ParentNSRequired (compose.go has the comment "don't join user NS for SSH to work correctly"). system connection add doesn't have that annotation, and it isn't excluded in can_use_shortcut() in pkg/rootless/rootless_linux.c either.
Steps to reproduce the issue
- As a rootless user, confirm ssh user@host true works and the host is in ~/.ssh/known_hosts.
- podman --ssh native system connection add test ssh://user@host/run/user/1000/podman/podman.sock
- Optional, the same failure in its simplest form: podman unshare ssh user@host true
Describe the results you received
Error: exit status 255
strace -f -e trace=write shows what ssh printed:
hostkeys_find_by_key_hostfile: hostkeys_foreach failed for /root/.ssh/known_hosts: Permission denied
ssh_askpass: exec(/usr/lib/ssh/ssh-askpass): No such file or directory
Host key verification failed.
podman unshare ssh user@host true also exits 255. Under unshare, ssh additionally complains Bad owner or permissions on /etc/ssh/ssh_config.d/20-systemd-ssh-proxy.conf.
Describe the results you expected
The connection gets added, using the calling user's ssh config, known_hosts and keys. If ssh does fail, podman should show ssh's stderr: nativeConnectionCreate in go.podman.io/common/pkg/ssh/connection_native.go never sets info.Stderr.
podman info output
host:
arch: amd64
buildahVersion: 1.45.2
cdiSpecDirs:
- /etc/cdi
- /var/run/cdi
cgroupControllers:
- cpu
- memory
- pids
cgroupManager: systemd
cgroupVersion: v2
conmon:
package: conmon-1:2.2.1-1
path: /usr/bin/conmon
version: 'conmon version 2.2.1, commit: c8cc2c4db27531bd4e084ce7857f73cd21ee639d'
cpuUtilization:
idlePercent: 88.11
systemPercent: 2.25
userPercent: 9.64
cpus: 8
databaseBackend: sqlite
distribution:
distribution: arch
version: unknown
emulatedArchitectures:
- linux/arm
- linux/arm64
- linux/arm64be
- linux/loong64
- linux/mips
- linux/mips64
- linux/ppc
- linux/ppc64
- linux/ppc64le
- linux/riscv32
- linux/riscv64
- linux/s390x
eventLogger: journald
freeLocks: 1854
hostname: nb-xps
idMappings:
gidmap:
- container_id: 0
host_id: 1000
size: 1
- container_id: 1
host_id: 100000
size: 65536
uidmap:
- container_id: 0
host_id: 1000
size: 1
- container_id: 1
host_id: 100000
size: 65536
kernel: 7.2.11-zen1-1-zen
linkmode: dynamic
logDriver: journald
memAvailable: 12299583488
memFree: 10750283776
memTotal: 33342234624
networkBackend: netavark
networkBackendInfo:
backend: netavark
defaultNetwork: podman
dns:
package: aardvark-dns-2.1.0-3
path: /usr/lib/podman/aardvark-dns
version: aardvark-dns 2.1.0
package: netavark-2.1.0-3
path: /usr/lib/podman/netavark
version: netavark 2.1.0
ociRuntime:
name: crun
package: crun-nikicat-git-1.27.r7.gca6e6729-1
path: /usr/bin/crun
version: |-
crun version 1.27.0.0.0.7-ca6e
commit: ca6e6729a70b5ea7dcd6ee2655d9d0740a08268b
rundir: /run/user/1000/crun
spec: 1.0.0
+SYSTEMD +SELINUX +APPARMOR +CAP +SECCOMP +EBPF +CRIU +YAJL
os: linux
pasta:
executable: /usr/bin/pasta
package: passt-2026_10_02.cba3570-1
version: |
pasta 2026_10_02.cba3570
Copyright Red Hat
GNU General Public License, version 2 or later
<https://www.gnu.org/licenses/old-licenses/gpl-2.0.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
remoteSocket:
exists: true
path: /run/user/1000/podman/podman.sock
rootlessNetworkCmd: pasta
rootlessPortForwarder: rootlessport
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: false
serviceIsRemote: false
swapFree: 0
swapTotal: 34359734272
uptime: 252h 39m 45.00s (Approximately 10.50 days)
variant: ""
plugins:
authorization: null
log:
- k8s-file
- none
- passthrough
- journald
network:
- bridge
- macvlan
- ipvlan
volume:
- local
registries:
search:
- docker.io
store:
containerStore:
number: 65
paused: 0
running: 42
stopped: 23
graphDriverName: overlay
graphOptions:
overlay.mountopt: nodev
graphRoot: /home/nb/.local/share/containers/storage
graphRootAllocated: 2773671788544
graphRootUsed: 2493211025408
graphStatus:
Backing Filesystem: extfs
Native Overlay Diff: "true"
Supports d_type: "true"
Supports shifting: "false"
Supports volatile: "true"
Using metacopy: "false"
imageCopyTmpDir: /var/tmp
imageStore:
number: 526
runRoot: /run/user/1000/containers
transientStore: false
volumePath: /home/nb/.local/share/containers/storage/volumes
version:
APIVersion: 6.1.4
Built: 1791874901
BuiltTime: Tue Oct 13 10:01:41 2026
GitCommit: 464c15fec06f0074c916f9eff87c4806869c2833
GoVersion: go1.27.2-X:nodwarf5
Os: linux
OsArch: linux/amd64
Version: 6.1.4
Podman in a container
No
Privileged Or Rootless
Rootless
Upstream Latest Release
Yes
Additional environment details
Arch Linux, podman 6.1.4-1, openssh 10.6p1-2.
Additional information
I tried --ssh native because the default Go ssh client fails on my known_hosts (golang/go#82871). Possibly related:
- #17090: image scp had similarly confusing SSH errors.
- #23831 (closed as stale): --ssh native isn't used for API connections, so even after the connection is added, the connection to the podman API socket still goes through the Go client.
Hi, I'd like to work on this if no one already is :). I'm looking into ParentNSRequired, the C shortcut exclusion, and regression coverage.
Hi @nadav78, are you still working on this? Is it okay if I take this and work on it, since I recently worked in this area (#30305)? If you have time, can you let me know?
Sorry @nadav78, you already made a PR for this (#30142), I only saw it today in the list below. I'll work on another area then.