mirror of
https://github.com/taigrr/nats.docs
synced 2025-01-18 04:03:23 -08:00
wip
This commit is contained in:
@@ -12,30 +12,38 @@ If you have [go installed](https://golang.org/doc/install), you can easily insta
|
||||
> go get github.com/nats-server/util/mkpasswd
|
||||
```
|
||||
|
||||
Alternatively, you can
|
||||
Alternatively, you can:
|
||||
|
||||
```
|
||||
> git clone git@github.com:nats-io/nats-server
|
||||
> cd nats-server/util/mkpasswd
|
||||
> go build mkpasswd.go
|
||||
> ./mkpasswd
|
||||
> go install mkpasswd.go
|
||||
```
|
||||
|
||||
## Generating bcrypted passwords
|
||||
With `mkpasswd` installed:
|
||||
```
|
||||
> mkpasswd
|
||||
pass: #IclkRPHUpsTmACWzmIGXr
|
||||
bcrypt hash: $2a$11$3kIDaCxw.Glsl1.u5nKa6eUnNDLV5HV9tIuUp7EHhMt6Nm9myW1aS
|
||||
```
|
||||
|
||||
If you already have a password selected, you can supply the `-p` flag on the command line, enter your desired password, and a `bcrypt` hash will be generated for it:
|
||||
|
||||
```
|
||||
> ./mkpasswd -p
|
||||
> mkpasswd -p
|
||||
Enter Password: *******
|
||||
Reenter Password: ******
|
||||
bcrypt hash: $2a$11$3kIDaCxw.Glsl1.u5nKa6eUnNDLV5HV9tIuUp7EHhMt6Nm9myW1aS
|
||||
```
|
||||
|
||||
Add the hash into the server configuration file's authorization section.
|
||||
To use the password on the server, add the hash into the server configuration file's authorization section.
|
||||
|
||||
```
|
||||
authorization {
|
||||
user: derek
|
||||
password: $2a$11$3kIDaCxw.Glsl1.u5nKa6eUnNDLV5HV9tIuUp7EHhMt6Nm9myW1aS
|
||||
}
|
||||
```
|
||||
```
|
||||
|
||||
Note the client will still have to provide the plain text version of the password, the server however will only store the hash to verify that the password is correct when supplied.
|
||||
|
||||
29
nats_tools/nk.md
Normal file
29
nats_tools/nk.md
Normal file
@@ -0,0 +1,29 @@
|
||||
# NK
|
||||
|
||||
`nk` is a command line tool that generates `nkeys`. NKeys are a highly secure public-key signature system based on [Ed25519](https://ed25519.cr.yp.to/).
|
||||
|
||||
With NKeys the server can verify identity without ever storing secrets on the server. The authentication system works by requiring a connecting client to provide its public key and digitally sign a challenge with its private key. The server generates a random challenge with every connection request, making it immune to playback attacks. The generated signature is validated a public key, thus proving the identity of the client. If the public key validation succeeds, authentication succeeds.
|
||||
|
||||
> NKey is an awesome replacement for token authentication, because a connecting client will have to prove it controls the private key for the authorized public key.
|
||||
|
||||
### Installing nk
|
||||
|
||||
To get started with NKeys, you’ll need the `nk` tool from https://github.com/nats-io/nkeys/nk repository. If you have _go_ installed, enter the following at a command prompt:
|
||||
|
||||
```bash
|
||||
> go get github.com/nats-io/nk
|
||||
```
|
||||
|
||||
### Generating NKeys and Configuring the Server
|
||||
|
||||
To generate a _User_ NKEY:
|
||||
|
||||
```
|
||||
> nk -gen user -pubout
|
||||
SUACSSL3UAHUDXKFSNVUZRF5UHPMWZ6BFDTJ7M6USDXIEDNPPQYYYCU3VY
|
||||
UDXU4RCSJNZOIQHZNWXHXORDPRTGNJAHAHFRGZNEEJCPQTT2M7NLCNF4
|
||||
```
|
||||
|
||||
The first output line starts with the letter `S` for _Seed_. The second letter `U` stands for _User_. Seeds are private keys; you should treat them as secrets and guard them with care.
|
||||
|
||||
The second line starts with the letter `U` for _User_, and is a public key which can be safely shared.
|
||||
Reference in New Issue
Block a user