Bug 3343 - Display host provided as argument with "ssh -G"
Summary: Display host provided as argument with "ssh -G"
Status: CLOSED FIXED
Alias: None
Product: Portable OpenSSH
Classification: Unclassified
Component: ssh (show other bugs)
Version: 8.7p1
Hardware: Other All
: P5 enhancement
Assignee: Assigned to nobody
URL:
Keywords:
Depends on:
Blocks: V_9_2
  Show dependency treegraph
 
Reported: 2021-08-26 17:49 AEST by Vincent Bernat
Modified: 2023-03-17 13:41 AEDT (History)
2 users (show)

See Also:


Attachments
Add original hostname to output of "ssh -G" (1.30 KB, patch)
2021-08-26 17:49 AEST, Vincent Bernat
no flags Details | Diff
Move host_arg into config struct and add to -G output (3.40 KB, patch)
2021-08-27 14:14 AEST, Darren Tucker
djm: ok+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Vincent Bernat 2021-08-26 17:49:36 AEST
Created attachment 3546 [details]
Add original hostname to output of "ssh -G"

Hey!

In some occasions, it is interesting to be able to extract the host provided as an argument. In my case, this is useful when wrapping the SSH command to update the window title with the hostname or add additional arguments depending on the target host. This can currently be done with `ssh -G` but the returned hostname is the `Hostname` option which may not match the hostname provided on the command-line. In my case, it is often an IP address which is not helpful to display as a window title.

Would it be possible to add the original hostname to the output of `ssh -G`? Attached a tiny patch for this purpose.
Comment 1 Darren Tucker 2021-08-27 13:23:11 AEST
The output of ssh -G is itself a valid ssh_config(5) and we have a test that checks that (which occasionally does pick up problems).

Your change as is would break that, but outputting it as a Host line should work.
Comment 2 Darren Tucker 2021-08-27 14:14:42 AEST
Created attachment 3547 [details]
Move host_arg into config struct and add to -G output
Comment 3 Vincent Bernat 2021-09-21 22:00:26 AEST
Hey!

As 8.8 is around the corner, am I expected to do something to make this move forward? I have tested the patch on master of openssh-portable and it works fine for me.
Comment 4 Vincent Bernat 2022-02-25 20:15:14 AEDT
Just in case, running the patch on top of 8.8 portable, no issue on my side.
Comment 5 Darren Tucker 2023-01-13 14:02:45 AEDT
This has been committed and will be in the 9.2 release.  Thanks for the report.
Comment 6 Damien Miller 2023-03-17 13:41:13 AEDT
OpenSSH 9.3 has been released. Close resolved bugs