assh icon indicating copy to clipboard operation
assh copied to clipboard

Nested host resolution

Open zhaofengli opened this issue 6 years ago • 0 comments

Consider the following assh.yml:

hosts:
  '*.ec2':
    Comment:
      - AWS EC2 Hosts
      - e.g. i-12345.us-west-1.ec2
    ResolveCommand: /bin/sh -c "aws ec2 describe-instances --region $(echo %h | cut -d '.' -f2) --instance-ids $(echo %h | cut -d '.' -f1) --query 'Reservations[].Instances[].PublicDnsName' | sed -n 2p - | tr -d '[ \"]'"
  bastion:
    HostName: i-12345.us-west-1.ec2

(The ResolveCommand is pretty ugly - I know 😜)

If I have a machine in us-west-1 with ID i12345, I can do ssh i-12345.us-west-1.ec2 just fine and assh will invoke AWS CLI to get the correct public address.

However, if I do ssh bastion, assh will only resolve it to i-12345.us-west-1.ec2 and attempts to connect to it directly.

I see that assh currently only do one pass of matching, but it would be really nice if assh could handle nested host resolution like this. We could have an option named NestedResolve that would trigger this behavior on a per-host basis.

Am I missing anything here? Or is there any workaround to achieve my desired results? Thanks a lot.

zhaofengli avatar Jun 25 '18 08:06 zhaofengli