Bug 3124 - Add a token to expand to remote hostname without domain name
Summary: Add a token to expand to remote hostname without domain name
Status: NEW
Alias: None
Product: Portable OpenSSH
Classification: Unclassified
Component: ssh (show other bugs)
Version: 8.2p1
Hardware: amd64 All
: P5 enhancement
Assignee: Assigned to nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-02-25 20:02 AEDT by mmoya
Modified: 2020-02-25 20:02 AEDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description mmoya 2020-02-25 20:02:07 AEDT
Add a token (say %H) for expanding the remote hostname *without* the domain name.

This feature will be useful to make config more clear when setting up access through a bastion host.

Right now, getting the remote hostname (without domain name) can be achieved with a shell hack.

Example config:

```
Host *.proj
  ConnectTimeout 5
  IdentityFile ~/.ssh/id_ecdsa-proj

Host *.prod.proj
  ProxyCommand ssh 1.2.3.4 -W $(echo %h | cut -d. -f1):%p

Host *.staging.proj
  ProxyCommand ssh 2.3.4.5 -W $(echo %h | cut -d. -f1):%p
```

compare that to something like:

```
Host *.proj
  Hostname %H  # a hypothetical new token expanding to the host part of the remote hostname
  ConnectTimeout 5
  IdentityFile ~/.ssh/id_ecdsa-proj

Host *.prod.proj
  ProxyJump 1.2.3.4

Host *.staging.proj
  ProxyJump 2.3.4.5
```

Thanks