Bug 3343

Summary: Display host provided as argument with "ssh -G"
Product: Portable OpenSSH Reporter: Vincent Bernat <vincent>
Component: sshAssignee: Assigned to nobody <unassigned-bugs>
Status: CLOSED FIXED    
Severity: enhancement CC: djm, dtucker
Priority: P5    
Version: 8.7p1   
Hardware: Other   
OS: All   
Bug Depends on:    
Bug Blocks: 3480    
Attachments:
Description Flags
Add original hostname to output of "ssh -G"
none
Move host_arg into config struct and add to -G output djm: ok+

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