Nerves_ssh error on ssh nerves.local

I’m following the Build a Weather Station with Elixir and Nerves book. I’ve run mix burn to an SSD card, inserted that card into a Raspberry Pi Zero W, and connected through a USB cable. However, when running ssh nerves.local I get the error message:

**Error** ** (SyntaxError) nofile:6:6: unexpected token: "$" (column 6, code point U+0024)
                            |
                               6 | hook=$(printf "{\"hook\": \"SSH\", \"value\": {\"socket_path\": \"~/.ssh/\", \"user\": \"%s\", \"host\": \"%s\", \"remote_shell\": \"%s\"}}" "$_user" "$_hostname" "${SHELL##*/}" | command od -An -v -tx1 | command tr -d " \n")
               |      ^
                           (elixir 1.14.2) lib/code.ex:424: Code.validated_eval_string/3
                          (nerves_ssh 0.4.1) lib/nerves_ssh/exec.ex:23: NervesSSH.Exec.run/1
                              (ssh 4.15.3) ssh_cli.erl:752: anonymous fn/4 in :ssh_cli.exec_in_self_group/5
                                         Connection to nerves.local closed.

Does anyone know why this happens?

1 Like

Does it show up in your network settings? If so, can you successfully ping it with ping nerves.local?

If not, it might be worth double checking the USB cable to make sure it supports data. Also, if memory serves, one of the ports on the Raspberry Pi Zero W is power only.

Updated: the USB data cable needs to be plugged into the middle one – the other port is power only. Connecting to Nerves Target via a USB data cable | Nerves docs

1 Like

Thanks for your reply, @codeanpeace!

It does show up in the network settings and I can successfully ping it. So I should be able to ssh to it, which is why I’m a little perplexed by the error.

Yeah, that’s quite odd… Just a sanity check, did you specify rpi0 as the mix target when fetching dependencies, creating the firmware, and burning it onto the sd card?

The execution on connection is not starting an Elixir shell and is instead running some sort of custom code. Did you alter any :nerves_ssh settings in your config or have settings in your ~/.ssh/config for the nerves.local host which is attempting to send some bash command on connect?

1 Like

I didn’t alter any :nerves_ssh settings in my config or add settings for the nerves.local host. I’m working with a completely fresh nerves project with nothing changed.

Any update on this?

I’m having exactly this issue after running

fwup circuits_quickstart_rpi0.fw

Resolved for me. This was an issue with the terminal I was using (Warp).

See here: Invalid autocommand in SSH configuration · Issue #2836 · warpdotdev/Warp · GitHub

Thanks @fhunleth for helping on Elixir Slack!

3 Likes