vincenzosuraci / hassio_ngrok

This custom-component allows to create automatically a ngrok tunnel and keep it open. So, if you are under a CGNAT (no way to have a public IPv4), this custom-component helps to get access to the Home Assistant web interface.
Apache License 2.0
16 stars 9 forks source link

ngrok authtoken returned non-zero exit status 127 #1

Open richard-scott opened 5 years ago

richard-scott commented 5 years ago

I'm getting this error when starting up:

2019-05-24 14:52:09 DEBUG (MainThread) [ngrok_init] async_setup()
2019-05-24 14:52:09 DEBUG (MainThread) [ngrok_init] /config dir exists
2019-05-24 14:52:09 DEBUG (MainThread) [ngrok_init] /config/.ngrock/ngrok file found.
2019-05-24 14:52:09 DEBUG (MainThread) [ngrok_init] Changing working directory to: /config/.ngrock
2019-05-24 14:52:09 DEBUG (MainThread) [ngrok_init] working directory is: /config/.ngrock
2019-05-24 14:52:09 DEBUG (MainThread) [ngrok_init] Executing: ['./ngrok authtoken 6KHcP79yxChxDsXSSfUrL_2MGtyF3ndAyp3Lcdw8Hva']
2019-05-24 14:52:09 ERROR (MainThread) [ngrok_init] Permission error
2019-05-24 14:52:09 DEBUG (MainThread) [ngrok_init] Command '['./ngrok authtoken 6KHcP79yxChxDsXSSfUrL_2MGtyF3ndAyp3Lcdw8Hva']' returned non-zero exit status 127.
2019-05-24 14:52:09 DEBUG (MainThread) [ngrok_init] 0o100
2019-05-24 14:52:09 DEBUG (MainThread) [ngrok_init] 0o100
2019-05-24 14:52:09 DEBUG (MainThread) [ngrok_init] True
2019-05-24 14:52:09 DEBUG (MainThread) [ngrok_init] async_update_devices_status()
2019-05-24 14:52:09 DEBUG (MainThread) [ngrok_init] Connecting to http://localhost:4040/api/tunnels
2019-05-24 14:52:09 ERROR (MainThread) [ngrok_init] <urlopen error [Errno 111] Connection refused>
2019-05-24 14:52:18 DEBUG (MainThread) [ngrok_init] async_periodic_update_ngrok_status()

When I run this as root, I get this:

Authtoken saved to configuration file: /root/.ngrok2/ngrok.yml
vincenzosuraci commented 5 years ago

If you crawl the log, you will discover that he Error Is a Permission Error. It means that you are not allowed to execute the ngrok application. Change the permissions, otherwise the custom component cannot work properly.

VS

richard-scott commented 5 years ago

Nope, not permissions on the ngrok application binary as it was this script that downloaded it.

vincenzosuraci commented 5 years ago

For sure, the execution of this command: ./ngrok authtoken 6KHcP79yxChxDsXSSfUrL_2MGtyF3ndAyp3Lcdw8Hva failed.

You are right, it is not strictly an execution permission error, indeed the ngrok file has permission code with Octal value of 100, that, in linux, has the symbolic value of ---x------.

The custom component, after downloading and unzipping the ngrok file, checks if it can be executed:

# make ngrok file executable
if not os.access(ngrok_file + ext, os.X_OK):
    os.chmod(ngrok_file_ext, stat.S_IEXEC)

If I were you, I would first test if the downloaded ngrok file works (access to it using SSH) and, once moved in the /config/.ngrok directory, give manually the command ./ngrok authtoken 6KHcP79yxChxDsXSSfUrL_2MGtyF3ndAyp3Lcdw8Hva and check if it works.

richard-scott commented 5 years ago

It seems that using this with the Hassio (Docker) version of HA doesn't seem to work as I can not execute /config/.ngrock/ngrok in the HA Docker Container.

However, I can execute this on the Docker Host with this path /usr/share/hassio/homeassistant/.ngrock/ngrok

It looks like mount of /config inside the Docker container doesn't allow execute ability for that binary. Shell scripts can execute just fine, but no the ngrok binary.