Skip to content

Latest commit

 

History

History
116 lines (81 loc) · 2.68 KB

nmctl-standalone.rst

File metadata and controls

116 lines (81 loc) · 2.68 KB

NMCTL - how to use netmaker from command line

a brief guide to using netmaker from the command line (without the UI)

Assumptions

  1. using bash shell
  2. nmctl and jq have been installed
  3. netmaker server has been set up at example.com. This can be a SaaS (managed) tenant as well.

Setup superadmin user

Set base domain

export NN_DOMAIN=example.com

Create SuperAdmin User

curl --location 'https://api.$NM_DOMAIN/api/users/adm/createsuperadmin' \
--header 'Content-Type: application/json' \
--data '{
"username":"superadmin",
"password":"NetmakerIsAwe$ome"
}'

Set Context

nmctl context set commandline --endpoint https://api.$NM_DOMAIN --username $USER --password $PASSWORD

Create Admin User

nmctl user create --admin --name $USER --password $PASSWORD

Create Normal User

nmctl user create --name <user> --password <user-password>

Normal Operations by user

assume that users have been created by superadmin

Set username/password

export USER=<user>
export PASSWORD=<user-password>

Set User Context

nmctl context set commandline --endpoint https://api.$NM_DOMAIN --username $USER --password $PASSWORD
nmctl context use commandline

Create Network

nmctl network create --name mynetwork --ip4v_addr 10.10.10.0/24

Create Enrollment Key

create one of Unlimited/LimitedUse/Expiration

Unlimited

export KEY=$(nmctl enrollment_key create --network mynetwork --unlimited | jq .token)

Limited Use (3)

export KEY=$(nmctl enrollment_key create --network mynetwork --uses 3 | jq .token)

With Expiration Time (2 days)

export EXPIRES=$(date -d "+2 days" +$s)
export KEY=$(nmctl enrollment_key create --network mynetwork --expires $EXPIRES | jq .token)

Join network

sudo netclient join -t $KEY