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

Auth token? #4

Open
jhagege opened this issue Jul 7, 2016 · 11 comments
Open

Auth token? #4

jhagege opened this issue Jul 7, 2016 · 11 comments

Comments

@jhagege
Copy link

jhagege commented Jul 7, 2016

Thanks a lot looks great !!!
How can I add an auth token ?
I tried docker run ngrok-container ngrok authtoken 'authToken' but it writes me:

t=2016-07-07T14:52:06+0000 lvl=warn msg="failed to get home directory, using $HOME instead" err="user: Current not implemented on linux/amd64" $HOME=/home/ngrok
Failed to save authtoken to configuration file '/home/ngrok/.ngrok2/ngrok.yml': open /home/ngrok/.ngrok2/ngrok.yml: permission denied
@jhagege
Copy link
Author

jhagege commented Jul 7, 2016

Would it be hard to programatically support changing env variable NGROK_AUTH ?

@wernight
Copy link
Owner

wernight commented Jul 8, 2016

Ah thanks I cannot test this but it seems like an easy fix.

Normally the access right should be fine thanks to this line:

chown ngrok:ngrok /home/ngrok

Are you mounting volumes? Running as another user?

@jhagege
Copy link
Author

jhagege commented Jul 8, 2016

Thanks for the fast answer.

Here is my Dockerfile:
FROM wernight/ngrok:latest
ENV NGROK_AUTH 'auth_key'
CMD ["ngrok", "start", "--none"]

@wernight
Copy link
Owner

wernight commented Jul 8, 2016

If you specify CMD you cannot use environment variables. Updating README. Either using only environment variables, or use only the CMD and put the token in the command-line.

wernight added a commit that referenced this issue Jul 8, 2016
@jhagege
Copy link
Author

jhagege commented Jul 8, 2016

Interesting, I would like the service to be started when the container launches, and don't want the users to manually run the command ngrok start --none.
Could you think of a workaround for it to work out-of-the box?
I tried putting in the CMD the auth key but didn't succeed for some reason...

Thanks a lot for your help!

@wernight
Copy link
Owner

wernight commented Jul 8, 2016

NGROK_AUTH does only generate a command-line like:

`ngrok http -authtoken=$TOKEN -log stdout`

@jhagege
Copy link
Author

jhagege commented Jul 8, 2016

Now I understand better thanks.
Still I would be very glad to be able to set the authtoken programmatically with an ENV variable NGROK_AUTH, because multiple devs are gonna use the same image, and the only change between each would be the auth token...

@jhagege
Copy link
Author

jhagege commented Jul 10, 2016

Do you think the other docker images of ngrok (including the ones you forked from) could work out for my use case ?
Thanks

@wernight
Copy link
Owner

I've seen none doing a ngrok start --none. You can just create a Dockerfile and extend this one, or use docker-compose.yml to write your environment.

@j796160836
Copy link
Contributor

j796160836 commented Aug 20, 2017

Ah ha! I figure out the problem is.
I found the default config file's owner is root, not ngrok user.

/ $ ls -al /home/ngrok/.ngrok2/ngrok.yml
-rw-r--r--    1 root     root            23 Jul  4 07:38 /home/ngrok/.ngrok2/ngrok.yml

that will cause error for ngrok authtoken command

My workaround fix

First, I make a Dockerfile for fix this issue

$ vi Dockerfile

content as follows

FROM wernight/ngrok:latest
USER root
RUN chown -R ngrok:ngrok /home/ngrok/
USER ngrok

(or change it to RUN chown ngrok:ngrok /home/ngrok/.ngrok2/ngrok.yml)
Second, build it as new image

$ docker build . -t  j/ngrok:latest

then use it

$ docker run --rm -it j/ngrok sh -c "ngrok authtoken MY_AUTH_TOKEN ; ngrok tcp 12345"

replace MY_AUTH_TOKEN to yours

Maybe I solution is not the best answer, but works.

@sasha-x
Copy link

sasha-x commented Aug 25, 2019

Same shit with ngrok installed from snap on ubuntu 18 laptop:

$ ngrok authtoken <token>
ERROR:  Failed to save authtoken to configuration file '/home/alex/.ngrok2/ngrok.yml': open /home/alex/.ngrok2/ngrok.yml: permission denied

And ok with unzipped one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants