Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ResolveCommand results in FATAL error #117

Closed
edi-design opened this issue Feb 19, 2016 · 6 comments · Fixed by #118
Closed

ResolveCommand results in FATAL error #117

edi-design opened this issue Feb 19, 2016 · 6 comments · Fixed by #118
Assignees
Labels
Milestone

Comments

@edi-design
Copy link

Hey,

I tried this now for almost two hours and I am sorry, but I can't find any solution for this.
I have a lot of hosts under one domain and i'd like to not type the full hostname everytime i would like to connect.

I tried to solve this by using the ResolveCommand.

My config:

hosts:

  "*.fresh":
    ResolveCommand: /bin/sh -c "echo $(echo %h | sed s/.fresh//).freshest.me"
    Inherits:
    - private-template


templates:
  # Templates are similar to Hosts, you can inherits from them
  # but you cannot ssh to a template
  work-template:
    User: worker
  private-template:
    User: andre

defaults:
  # Defaults are applied to each hosts
  ControlMaster: auto
  ControlPath: ~/tmp/.ssh/cm/%h-%p-%r.sock
  ControlPersist: yes
  Port: 22
  User: andre
  TCPKeepAlive: yes
  ServerAliveInterval: 10
  ForwardAgent: yes
  IdentityFile: ~/.ssh/id_rsa

includes:
- ~/.ssh/hosts/*.yml

The following error:

> $ ssh www.fresh
DEBU[0000] assh args: [www.fresh]
DEBU[0000] Loading config file '/Users/andre/.ssh/assh.yml'
DEBU[0000] Loaded config file '/Users/andre/.ssh/assh.yml' (0 + 2 => 2 hosts)
DEBU[0000] Loading config file '/Users/andre/.ssh/hosts/backend-a.yml'
DEBU[0000] Loaded config file '/Users/andre/.ssh/hosts/backend-a.yml' (2 + 7 => 5 hosts)
DEBU[0000] Loading config file '/Users/andre/.ssh/hosts/dev.yml'
DEBU[0000] Loaded config file '/Users/andre/.ssh/hosts/dev.yml' (7 + 10 => 3 hosts)
DEBU[0000] Loading config file '/Users/andre/.ssh/hosts/private.yml'
DEBU[0000] Loaded config file '/Users/andre/.ssh/hosts/private.yml' (10 + 14 => 4 hosts)
DEBU[0000] getHostByName pattern matching: "*.fresh" => "www.fresh"
INFO[0000] Host www.fresh
INFO[0000]   ControlMaster auto
INFO[0000]   ControlPath ~/tmp/.ssh/cm/%h-%p-%r.sock
INFO[0000]   ControlPersist yes
INFO[0000]   ForwardAgent yes
INFO[0000]   HostName www.fresh
INFO[0000]   IdentityFile ~/.ssh/id_rsa
INFO[0000]   Port 22022
INFO[0000]   ServerAliveInterval 10
INFO[0000]   TCPKeepAlive yes
INFO[0000]   User andre
INFO[0000]   # Inherits: [private-template]
INFO[0000]   # ResolveCommand: /bin/sh -c "echo (echo %h | sed s/.fresh//).freshest.me"
DEBU[0000] Saving SSH config
DEBU[0000] Writing SSH config file to "/Users/andre/.ssh/config"
DEBU[0000] Proxying
DEBU[0000] Connecting without gateway
DEBU[0000] Preparing host object
DEBU[0000] Resolving host: "www.fresh" using command: "/bin/sh -c \"echo (echo www.fresh | sed s/.fresh//).freshest.me\""
FATA[0000] Proxy error: exit status 2
ssh_exchange_identification: Connection closed by remote host

Hopefully someone could help me.

Thank you very much.

Best regards,
André

@moul moul added the Bug label Feb 19, 2016
@moul moul self-assigned this Feb 19, 2016
@moul
Copy link
Owner

moul commented Feb 19, 2016

Hi @edi-design, thank you for reporting,

Your configuration looks good, there is probably a bug when executing commands with double-quotes, I need to give a deeper look

@moul
Copy link
Owner

moul commented Feb 19, 2016

It looks like the issue come from the dollar character

ResolveCommand: /bin/sh -c "echo $(echo %h | sed s/.fresh//).freshest.me"
# fatal error

ResolveCommand: /bin/sh -c "echo `echo %h | sed s/.fresh//`.freshest.me"
# resolving

I suggest you to switch to this syntax while I find a better solution

@moul
Copy link
Owner

moul commented Feb 19, 2016

I just fixed the issue in #118, if you upgrade to the latest version (brew upgrade assh --HEAD for instance), you will be able to use your favorite syntax :)

@moul moul closed this as completed in #118 Feb 19, 2016
moul added a commit that referenced this issue Feb 19, 2016
@moul moul removed the in progress label Feb 19, 2016
@moul
Copy link
Owner

moul commented Feb 19, 2016

do not hesitate to reopen the issue if the problem persists

@edi-design
Copy link
Author

Thank you very much.
It works now perfectly.

Again, thank you for your very fast fix and help.

@moul
Copy link
Owner

moul commented Feb 20, 2016

👍

@moul moul added this to the v2.3.0 milestone Mar 21, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants