# \`ziti edge controller create identity user\` causing error

**URL:** <https://openziti.discourse.group/t/ziti-edge-controller-create-identity-user-causing-error/441>\
**Category:** Building/Development\
**Created:** [April 26, 2022, 9:09am UTC](https://openziti.discourse.group/t/ziti-edge-controller-create-identity-user-causing-error/441 "2022-04-26T09:09:34Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![afzal442](https://yyz2.discourse-cdn.com/free1/user_avatar/openziti.discourse.group/afzal442/32/235_2.png) [@afzal442](https://openziti.discourse.group/u/afzal442)\
**Post date:** [April 26, 2022, 9:09am UTC](https://openziti.discourse.group/t/ziti-edge-controller-create-identity-user-causing-error/441/1 "2022-04-26T09:09:34Z")

</div>

Hi @markamind,  
Thanks much, when I try out this cmd `ziti edge controller create identity user "NewUser" -o NewUser.jwt`  
, it gives me error, saying `unknown shorthand flag: 'o' in -o`. Let me know if I’m missing something. Thanks.

---

<div class="post-metadata">

**Author:** ![markamind](https://yyz2.discourse-cdn.com/free1/user_avatar/openziti.discourse.group/markamind/32/157_2.png) [@markamind](https://openziti.discourse.group/u/markamind)\
**Post date:** [April 26, 2022, 9:27am UTC](https://openziti.discourse.group/t/ziti-edge-controller-create-identity-user-causing-error/441/2 "2022-04-26T09:27:58Z")

</div>

Have a look through these commands.. it may help with the structure.

Here is an example to create an identity called "server.id" that is linked to a service called "service.endpoint"

> ziti edge create identity device server.id -a service.endpoint -o server.jwt

This took me ages to work out.. and then there was those terminators.

> tip: terminators are only created when you start a host.. so for them to be created.. you need to run a service on the server that starts up the listener for a specific port.. or range of ports (using an intercept)

[https://raw.githubusercontent.com/openziti/ziti-doc/main/docfx\_project/articles/zitification/zitifying-ssh/zssh-cheat-sheet.md](https://raw.githubusercontent.com/openziti/ziti-doc/main/docfx_project/articles/zitification/zitifying-ssh/zssh-cheat-sheet.md)

---

<div class="post-metadata">

**Author:** ![afzal442](https://yyz2.discourse-cdn.com/free1/user_avatar/openziti.discourse.group/afzal442/32/235_2.png) [@afzal442](https://openziti.discourse.group/u/afzal442)\
**Post date:** [April 26, 2022, 12:00pm UTC](https://openziti.discourse.group/t/ziti-edge-controller-create-identity-user-causing-error/441/3 "2022-04-26T12:00:57Z")

</div>

After a couple of trials, I got into `unauthorised` access, something like below

```auto
ziti edge create identity device "${server_identity}" -a "${service_name}"ServerEndpoints -o "${server_identity}".jwt

error: error creating identities instance in Ziti Edge Controller at https://sig56/edge/management/v1. Status code: 401 Unauthorized, Server returned: {
    "error": {
        "code": "UNAUTHORIZED",
        "message": "The request could not be completed. The session is not authorized or the credentials are invalid",
        "requestId": "lP-RAlbui"
    },
    "meta": {
        "apiEnrollmentVersion": "0.0.1",
        "apiVersion": "0.0.1"
    }

```

```auto
curl eth0.me
223.233.21.219

```

Any clue plz?

---

<div class="post-metadata">

**Author:** ![markamind](https://yyz2.discourse-cdn.com/free1/user_avatar/openziti.discourse.group/markamind/32/157_2.png) [@markamind](https://openziti.discourse.group/u/markamind)\
**Post date:** [April 26, 2022, 12:13pm UTC](https://openziti.discourse.group/t/ziti-edge-controller-create-identity-user-causing-error/441/4 "2022-04-26T12:13:20Z")

</div>

ahh.. I believe you are very close.

> try this before you run the command

zitiLogin

This creates a token on your controller so that you can run ziti commands like enroll etc

---

<div class="post-metadata">

**Author:** ![afzal442](https://yyz2.discourse-cdn.com/free1/user_avatar/openziti.discourse.group/afzal442/32/235_2.png) [@afzal442](https://openziti.discourse.group/u/afzal442)\
**Post date:** [April 26, 2022, 12:16pm UTC](https://openziti.discourse.group/t/ziti-edge-controller-create-identity-user-causing-error/441/5 "2022-04-26T12:16:40Z")

</div>

hmmm! thanks worked for me.

I modified that as `ziti edge login` 😄

---

<div class="post-metadata">

**Author:** ![gberl002](https://yyz2.discourse-cdn.com/free1/user_avatar/openziti.discourse.group/gberl002/32/333_2.png) [@gberl002](https://openziti.discourse.group/u/gberl002)\
**Post date:** [April 26, 2022, 12:16pm UTC](https://openziti.discourse.group/t/ziti-edge-controller-create-identity-user-causing-error/441/6 "2022-04-26T12:16:54Z")

</div>

@afzal442 Can you please let me know where you found this command string?

`ziti edge controller create identity user`

I ask because I have seen this in some older documentation so I’d like to see if we can update or remove the docs.

Also, regarding your latest message @markamind has you covered, you just need to `zitiLogin` if you see that UNAUTHORIZED error.

---

<div class="post-metadata">

**Author:** ![afzal442](https://yyz2.discourse-cdn.com/free1/user_avatar/openziti.discourse.group/afzal442/32/235_2.png) [@afzal442](https://openziti.discourse.group/u/afzal442)\
**Post date:** [April 26, 2022, 12:19pm UTC](https://openziti.discourse.group/t/ziti-edge-controller-create-identity-user-causing-error/441/7 "2022-04-26T12:19:41Z")

</div>

Yes @gberl002 , sure!  
the associated link to that [Creating an Identity | Ziti](https://openziti.github.io/ziti/identities/creating.html#one-time-token-ott)

---

<div class="post-metadata">

**Author:** ![TheLumberjack](https://yyz2.discourse-cdn.com/free1/user_avatar/openziti.discourse.group/thelumberjack/32/113_2.png) [@TheLumberjack](https://openziti.discourse.group/u/TheLumberjack)\
**Post date:** [April 26, 2022, 1:56pm UTC](https://openziti.discourse.group/t/ziti-edge-controller-create-identity-user-causing-error/441/8 "2022-04-26T13:56:35Z")

</div>

We removed ‘controller’ a long time ago from commands like this and looks like we missed some spots it was referenced.

Seems like this ‘breaks’ that command! ☹ i’ll get that fixed up. The ‘correct’ command is to just remove ‘controller’

```auto
ziti edge controller create identity user "NewUser" -o NewUser.jwt

```

As for the UNAUTHORIZED issue - as you discovered your session just timed out and you needed to login again

---

<div class="post-metadata">

**Author:** ![gberl002](https://yyz2.discourse-cdn.com/free1/user_avatar/openziti.discourse.group/gberl002/32/333_2.png) [@gberl002](https://openziti.discourse.group/u/gberl002)\
**Post date:** [April 26, 2022, 2:06pm UTC](https://openziti.discourse.group/t/ziti-edge-controller-create-identity-user-causing-error/441/9 "2022-04-26T14:06:02Z")

</div>

I’m on it @TheLumberjack

---

<div class="post-metadata">

**Author:** ![afzal442](https://yyz2.discourse-cdn.com/free1/user_avatar/openziti.discourse.group/afzal442/32/235_2.png) [@afzal442](https://openziti.discourse.group/u/afzal442)\
**Post date:** [April 26, 2022, 2:23pm UTC](https://openziti.discourse.group/t/ziti-edge-controller-create-identity-user-causing-error/441/10 "2022-04-26T14:23:00Z")

</div>

Having that said I went through the examples associated with `go-sdk`, I am struggling with running the application. I tried out like for server.go → ` go run simple-server.go "$HOME/srv.conf” eth2`,  
similarly for client → `go run simple-client.go "$HOME/cli.conf” 80`

Before that I enrolled the jwt as `ziti edge enroll --jwt ${jwt_file} --out ${identity_config_file}`.  
Any hint plz? 🛩  
cc @TheLumberjack

---

<div class="post-metadata">

**Author:** ![TheLumberjack](https://yyz2.discourse-cdn.com/free1/user_avatar/openziti.discourse.group/thelumberjack/32/113_2.png) [@TheLumberjack](https://openziti.discourse.group/u/TheLumberjack)\
**Post date:** [April 26, 2022, 2:39pm UTC](https://openziti.discourse.group/t/ziti-edge-controller-create-identity-user-causing-error/441/11 "2022-04-26T14:39:47Z")

</div>

I can give you a bunch of commands that will get this up and running. I’ll do that and get back to you in a few minutes… 🙂

---

<div class="post-metadata">

**Author:** ![TheLumberjack](https://yyz2.discourse-cdn.com/free1/user_avatar/openziti.discourse.group/thelumberjack/32/113_2.png) [@TheLumberjack](https://openziti.discourse.group/u/TheLumberjack)\
**Post date:** [April 26, 2022, 3:11pm UTC](https://openziti.discourse.group/t/ziti-edge-controller-create-identity-user-causing-error/441/12 "2022-04-26T15:11:04Z")

</div>

Follow a quickstart, make sure you can login and issue ziti cli commands (i think you’re here already)

```auto
open two terminal windows
git clone git@github.com:openziti/sdk-golang.git
terminal 1: cd sdk-golang/exercises/http/server/zitified
terminal 1: ziti edge create identity user server.id -o server.id.jwt
terminal 1: ziti edge enroll server.id.jwt

terminal 2: cd sdk-golang/exercises/http/client/zitified
terminal 2: ziti edge create identity user client.id -o client.id.jwt
terminal 2: ziti edge enroll client.id.jwt

terminal 1: ziti edge create service simple-http-service
terminal 1: ziti edge create service-policy simple-http-service-bind Bind --service-roles '@simple-http-service' --identity-roles '@server.id'
terminal 1: ziti edge create service-policy simple-http-service-dial Dial --service-roles '@simple-http-service' --identity-roles '@client.id'

```

Here comes the payoff 🙂

```auto
terminal 2: go run simple-client.go client.id.json simple-http-service
Hello response: zitified hello from sg3
Add Result: zitified a+b=1+2=3

```

---

<div class="post-metadata">

**Author:** ![afzal442](https://yyz2.discourse-cdn.com/free1/user_avatar/openziti.discourse.group/afzal442/32/235_2.png) [@afzal442](https://openziti.discourse.group/u/afzal442)\
**Post date:** [April 27, 2022, 6:07am UTC](https://openziti.discourse.group/t/ziti-edge-controller-create-identity-user-causing-error/441/13 "2022-04-27T06:07:57Z")

</div>

hey @TheLumberjack, thanks much for your kind help. So now when I try to restart my ziti controller, `startZitiController: command not found` causes the issue. Or maybe I missed somewhere. Thanks

---

<div class="post-metadata">

**Author:** ![afzal442](https://yyz2.discourse-cdn.com/free1/user_avatar/openziti.discourse.group/afzal442/32/235_2.png) [@afzal442](https://openziti.discourse.group/u/afzal442)\
**Post date:** [April 27, 2022, 6:12am UTC](https://openziti.discourse.group/t/ziti-edge-controller-create-identity-user-causing-error/441/14 "2022-04-27T06:12:05Z")

</div>

Any hint plz?

cc @markamind

---

<div class="post-metadata">

**Author:** ![markamind](https://yyz2.discourse-cdn.com/free1/user_avatar/openziti.discourse.group/markamind/32/157_2.png) [@markamind](https://openziti.discourse.group/u/markamind)\
**Post date:** [April 27, 2022, 6:29am UTC](https://openziti.discourse.group/t/ziti-edge-controller-create-identity-user-causing-error/441/15 "2022-04-27T06:29:13Z")

</div>

There are two approaches to starting / stoping services

1. via cmd file (my preference for testing)
2. via system control.

If you want to do it via command.. you need to download a local copy of the ziti-cli-functions.sh file used to conduct the Quick Install

With this in a local directory.. the following should work

. ./ziti-cli-functions.sh && startZitiController

> to start the edge router, you need to set the following variable first  
> ZITI\_EDGE\_ROUTER\_RAWNAME=instance-20220416-1603-edge-router

. ./ziti-cli-functions.sh && startExpressEdgeRouter

In case you did setup the system command, it would be something like

sudo systemctl start ziti-controller  
sudo systemctl stop ziti-controller

sudo systemctl start ziti-edge-router  
sudo systemctl stop ziti-edge-router

sudo systemctl start ziti-console  
sudo systemctl stop ziti-console

Hope that helps 🙂

---

<div class="post-metadata">

**Author:** ![afzal442](https://yyz2.discourse-cdn.com/free1/user_avatar/openziti.discourse.group/afzal442/32/235_2.png) [@afzal442](https://openziti.discourse.group/u/afzal442)\
**Post date:** [April 27, 2022, 6:40am UTC](https://openziti.discourse.group/t/ziti-edge-controller-create-identity-user-causing-error/441/16 "2022-04-27T06:40:38Z")

</div>

Sorry @markamind, could you tell me where I can find local copy of the ziti-cli-functions.sh file to download? Thanks.  
FYI, I have this development setup with no docker.

---

<div class="post-metadata">

**Author:** ![markamind](https://yyz2.discourse-cdn.com/free1/user_avatar/openziti.discourse.group/markamind/32/157_2.png) [@markamind](https://openziti.discourse.group/u/markamind)\
**Post date:** [April 27, 2022, 6:54am UTC](https://openziti.discourse.group/t/ziti-edge-controller-create-identity-user-causing-error/441/17 "2022-04-27T06:54:09Z")

</div>

the file is the quick start install script.

```auto
# now download, source, and execute the expressInstall function
source /dev/stdin <<< "$(wget -qO- https://raw.githubusercontent.com/openziti/ziti/release-next/quickstart/docker/image/ziti-cli-functions.sh)"; expressInstall

```

It gets cached during the install… then automatically cleaned up

---

<div class="post-metadata">

**Author:** ![TheLumberjack](https://yyz2.discourse-cdn.com/free1/user_avatar/openziti.discourse.group/thelumberjack/32/113_2.png) [@TheLumberjack](https://openziti.discourse.group/u/TheLumberjack)\
**Post date:** [April 27, 2022, 4:12pm UTC](https://openziti.discourse.group/t/ziti-edge-controller-create-identity-user-causing-error/441/18 "2022-04-27T16:12:45Z")

</div>

@afzal442 there's a section of the doc that covers this here [https://openziti.github.io/ziti/quickstarts/network/local-no-docker.html#sourcing-the-env-file](https://openziti.github.io/ziti/quickstarts/network/local-no-docker.html#sourcing-the-env-file)

> In the case you close your shell and you want to get the same environment variables back into your shell, you can just source the "env" file that is placed into the location you specified. For example, if you ran the example above where the deployed files went to `${HOME}/.ziti/quickstart/newfolder` you would find an "env" file at `${HOME}/.ziti/quickstart/newfolder/newfolder.env` and source it:

```auto
source ${HOME}/.ziti/quickstart/newfolder/newfolder.env

~ % zitiLogin
Token: aa1c7fb0-85d9-4a79-86b2-5df450c5b4de
Saving identity 'default' to ${HOME}/.ziti/quickstart/newfolder/ziti-cli.json

```

Hope that's enough of a hint for you 🙂

---

<div class="post-metadata">

**Author:** ![TheLumberjack](https://yyz2.discourse-cdn.com/free1/user_avatar/openziti.discourse.group/thelumberjack/32/113_2.png) [@TheLumberjack](https://openziti.discourse.group/u/TheLumberjack)\
**Post date:** [April 27, 2022, 4:33pm UTC](https://openziti.discourse.group/t/ziti-edge-controller-create-identity-user-causing-error/441/19 "2022-04-27T16:33:21Z")

</div>

Oh, I realize I answered the question wrongly. You could choose to source the script from the web (like @markamind shows) every time with just running the same command (without the expressInstall function call)

```auto
source /dev/stdin <<< "$(wget -qO- https://raw.githubusercontent.com/openziti/ziti/release-next/quickstart/docker/image/ziti-cli-functions.sh)";

```

or you can just wget the file and put it somewhere ‘cached’:

```auto
wget -q -O /tmp/ziti-cli-functions.sh https://raw.githubusercontent.com/openziti/ziti/release-next/quickstart/docker/image/ziti-cli-functions.sh

```

then you can source THAT file when you want:

```auto
source /tmp/ziti-cli-functions.sh

```

I would get the latest ziti-cli-functions.sh now and then in case there’s bug fixes 🙂

---

<div class="post-metadata">

**Author:** ![afzal442](https://yyz2.discourse-cdn.com/free1/user_avatar/openziti.discourse.group/afzal442/32/235_2.png) [@afzal442](https://openziti.discourse.group/u/afzal442)\
**Post date:** [April 27, 2022, 6:32pm UTC](https://openziti.discourse.group/t/ziti-edge-controller-create-identity-user-causing-error/441/20 "2022-04-27T18:32:26Z")

</div>

hmmm! sounds good.

> every time with just running the same command (without the expressInstall function call)

Yep, I did that in those ways. It'll be nice if we can add it on docs as well so that one can't miss this step while starting `ziti controller` again. Thanks 😄
