[Bug 4016] New: ssh -G prints option values that contain spaces without quoting, so its output cannot be read back

bugzilla-daemon at mindrot.org bugzilla-daemon at mindrot.org
Thu Oct 8 13:59:20 AEDT 2026


https://bugzilla.mindrot.org/show_bug.cgi?id=4016

            Bug ID: 4016
           Summary: ssh -G prints option values that contain spaces
                    without quoting, so its output cannot be read back
           Product: Portable OpenSSH
           Version: 10.5p1
          Hardware: Other
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P5
         Component: ssh
          Assignee: unassigned-bugs at mindrot.org
          Reporter: khush2792001 at gmail.com

`ssh -G` is meant to print the configuration in a form ssh can read
again (regress/sshcfgparse.sh checks that).
Values set from a quoted argument that contains whitespace are printed
verbatim, without quotes, so the dump either
fails to parse or parses to a different value:

```
$ printf 'ControlPath "/tmp/a b"\n' > c1; ssh -G -F c1 host > d1; ssh
-G -F d1 host
d1 line 50: keyword controlpath extra arguments at end of line
$ printf 'SetEnv "FOO=a b"\n' > c1; ssh -G -F c1 host > d1; ssh -G -F
d1 host
d1 line 69: Invalid SetEnv.
$ printf 'UserKnownHostsFile "/tmp/a  b"\n' > c1; ssh -G -F c1 host |
grep ^userknown
userknownhostsfile /tmp/a  b
$ ssh -G -F c1 host > d1; ssh -G -F d1 host | grep ^userknown
userknownhostsfile /tmp/a b        <- one file name became two
```

`IdentityFile`, `IdentityAgent`, `HostKeyAlias`, `SendEnv` and
`LogVerbose` behave the same. A value without
whitespace round-trips. `dump_client_config()` in readconf.c prints the
strings as stored; quoting a value that
contains whitespace (or any character the parser treats specially)
would make the output readable again.

-- 
You are receiving this mail because:
You are watching the assignee of the bug.


More information about the openssh-bugs mailing list