key-networks / ztncui

ZeroTier network controller UI
GNU General Public License v3.0
1.52k stars 227 forks source link

Continue on Issue #107 - Error retrieving list of networks on this controller: HTTPError: Response code 401 (Unauthorized) #114

Closed angyen closed 1 year ago

angyen commented 1 year ago

Good day.

After I input the commands:- sudo -i echo ZT_TOKEN=cat /var/lib/zerotier-one/authtoken.secret>> /opt/key-networks/ztncui/.env chmod 400 /opt/key-networks/ztncui/.env chown ztncui.ztncui /opt/key-networks/ztncui/.env systemctl restart ztncui I am able to login again but when I go to "networks" tab, I am not able to see my existing networks. The following message is shown:

Error retrieving list of networks on this controller: HTTPError: Response code 401 (Unauthorized)

May I know how to resolve this?

angyen commented 1 year ago

May I know if you could assist on this?

taich001 commented 1 year ago

I fixed this with a bash script that will run every two minutes.

angyen commented 1 year ago

Could you share the bash script and how to apply it?

Thank you in advance.

key-networks commented 1 year ago

Did you execute exactly as per the instructions at https://key-networks.com/ztncui

sudo sh -c "echo ZT_TOKEN=`sudo cat /var/lib/zerotier-one/authtoken.secret` >> /opt/key-networks/ztncui/.env"

Note the backticks around sudo cat /var/lib/zerotier-one/authtoken.secret

angyen commented 1 year ago

Did you execute exactly as per the instructions at https://key-networks.com/ztncui

sudo sh -c "echo ZT_TOKEN=`sudo cat /var/lib/zerotier-one/authtoken.secret` >> /opt/key-networks/ztncui/.env"

Note the backticks around sudo cat /var/lib/zerotier-one/authtoken.secret

Yes I did.

and I just did it again so to make sure that all the command are entered correctly and the following are the screen shots of various tab after I executed the command for your reference.

I am still getting the Response code 401.

https://mptsd-my.sharepoint.com/:i:/g/personal/dr_mptsd_onmicrosoft_com/EctSrVfT9KZFsHtTz-yLPFcB59pZJwo1eN5ObcRBHzyrzA?e=5jEaCO

key-networks commented 1 year ago

Do you see a line in /opt/key-networks/ztncui/.env like: ZT_TOKEN=XXXXXXXXXXXXXXXXXXXXXXXX where XXXXXXXXXXXXXXXXXXXXXXXX is the content of /var/lib/zerotier-one/authtoken.secret?

Please show the output of: ls -l /opt/key-networks/ztncui/.env

key-networks commented 1 year ago

From your screenshot, you are not using backticks. Instead, you are using single quotes. Please see https://en.wikipedia.org/wiki/Backtick

key-networks commented 1 year ago

Backtick is normally directly under the esc key in the top left corner of your keyboard.

angyen commented 1 year ago

Thank you so much for pointing out my mistake It works now after I replaced the quote with backtick.

key-networks commented 1 year ago

Great to hear that - thanks for your feedback!

taich001 commented 1 year ago

Set the ZT_TOKEN in .env worked for me too.