moul/assh

"/bin/sh: nil: No such file or directory"

Closed this issue · 9 comments

For the life of me I can't figure out where this is coming from.

/bin/sh: nil: No such file or directory
New SSH connection to xxx@xxxx:222
Welcome to Ubuntu 14.04.5 LTS (GNU/Linux 3.13.0-106-generic x86_64)

For the life of me I cannot figure out where this /bin/sh: nil is being generated from. It's not causing any problems, and it doesn't show up when I run it in debug/verbose. Is anyone else seeing this?

*edited typo

moul commented

Hi @bdmorin,

Is there a typo in your comment? I can see /bin/sh in the example and /bin/ssh in the description, which one is the right one?

Can you give me the full command that fails so I can try to reproduce?

Thank you for your feedback!

The snippet is correct, I'm sorry. I fat fingered the error when I was typing it in.

-> % ssh bmorin@prodapp4
/bin/sh: nil: No such file or directory
New SSH connection to bdmorin@prodapp4:22
...

I only run assh on my desktop/laptop, but my dotfiles are pretty much the same. I'll try a fresh install on a new profile.

Looks like I found the issue:

        # Log internal information to a file
            - 'exec echo {{.}} | jq . >> ~/.ssh/last_connected_host.txt'

I commented out this line and that message went away. I have jq installed. I'll see if I can't figure out what's going on.

moul commented

Hi @bdmorin, I just made some changes (#256) that should be helpful for you, can you give a new try?

hbokh commented

FYI still not working on assh version 2.7.0 (HEAD); macOS 10.13.2; /usr/local/bin/zsh / "oh-my-zsh".

moul commented

@hbokh can you give a new try ? :)

hbokh commented

Merci, but no luck...
I ran brew unlink assh and brew install assh --HEAD which gave me /usr/local/bin/assh -> ../Cellar/assh/HEAD-95a790a/bin/assh.
When using this version it still shows the same "nil"-message:

# ssh some_host
/bin/sh: nil: No such file or directory
New SSH connection to ...

when using the config

    OnConnect:
      # Log internal information to a file
      - 'exec echo {{.}} | jq . >> ~/.ssh/last_connected_host.txt'

Do you need any more information from my side?

moul commented

I reproduced your error and found a workaround:

# use 
      - exec echo {{.|json|b64enc}} | base64 -D | jq . > ~/.ssh/last_connected_host.txt
# instead of
      - 'exec echo {{.}} | jq . >> ~/.ssh/last_connected_host.txt'

The error here was about a shell syntax error, because {{.}} returns a golang representation of a complex object that contains quotes, double quotes, backslashes etc

I tried to use exec echo {{.|json}} | jq . > ~/.ssh/last_connected_host.txt, which returns a json representation of the object instead of the golang one, but it's the same issue, shell syntax error


I will try to find a way to validate the syntax to display more comprehensive errors

hbokh commented

Superbe! The error is now gone, but you'll have to use base64 -d (lower caps d) instead.