Skip to content

Commit 5bb6bfb

Browse files
authored
Merge pull request #25 from ST2Projects/tk/6/documentation
Update readme and add api-docs.yml
2 parents 06dd01c + 8c000b7 commit 5bb6bfb

File tree

4 files changed

+188
-18
lines changed

4 files changed

+188
-18
lines changed

.goreleaser.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ archives:
1919
- samples
2020
- README.md
2121
- LICENSE
22-
- install/Makefile
2322
checksum:
2423
name_template: 'checksums.txt'
2524
snapshot:

README.md

Lines changed: 75 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,17 @@
22

33
A simple to use and deploy SSH CA server.
44

5-
**This is a Work In Progress** - the project is in its early days. It is functional and I'm using it for my own hosts **but** you use it at your own risk
5+
**This is a Work In Progress** - the project is in its early days. It is functional, and I'm using it for my own hosts, **but** you use it at your own risk
6+
7+
## Goals
8+
9+
There are a couple of SSH CA servers out there - I have found them all difficult to use and have specific platform
10+
requirements. This projects aims to:
11+
12+
- Be simple to use and deploy
13+
- Use sensible secure defaults
14+
15+
I'm also using this project to learn go, so if you come across it and notice something dumb please let me know by opening an issue!
616

717
## Installation
818

@@ -17,12 +27,14 @@ mkdir /opt/sentinel
1727
# Copy archive into directory
1828
tar xvzf ssh-sentinel-server_$VERSION_$ARCH.tar.gz
1929

20-
make install
30+
cp samples/config.json .
31+
cp samples/ssh-sentinel.service /etc/systemd/system/
32+
systemctl daemon-reload
2133
```
2234

23-
## Configuration
35+
### Configuration
2436

25-
Configuration is defined in the `config.json`. Properties are explained below. All paths are relative to the `resources` directory
37+
Configuration is defined in the `config.json`. Properties are explained below. Full paths must be provided
2638

2739
- `CAPrivateKey` - Name of the CA private key. The key must be unencrypted - a future enhancement will allow encrypted keys
2840
- `CAPublicKey` - Name of the CA public key.
@@ -32,14 +44,68 @@ Configuration is defined in the `config.json`. Properties are explained below. A
3244
- `db.password` - Password of the DB user
3345
- `db.connection` - Connection URL for the DB. For sqlite3 this is a file path
3446
- `db.dbName` - Name of the DB
47+
- `tls.local` - When set to `true` the server will generate a local TLS certificate. When `false` the server will generate a Let's Encrypt cert
48+
- `tls.certDir` - Directory in which the generated certificate will be generated
49+
- `tls.certDomains` - A list of domains to be included in the certificate.
50+
- `tls.certEmail` - Needed when generating a certificate with let's encrypt
51+
- `tls.dnsProvider` - Only `cloudflare` is supported at the moment. A future release will open up support for other providers
52+
- `tls.dnsAPIToken` - The zone API token from cloudflare
3553

36-
## Goals
54+
### Generate a CA
3755

38-
There are a couple of SSH CA servers out there - I have found them all difficult to use and have specific platform
39-
requirements. This projects aims to:
56+
You can generate a SSH CA with `ssh-keygen`. I suggest using ECDSA keys as they are smaller but this is not a requirement.
4057

41-
- Be simple to use and deploy
42-
- Use sensible secure defaults
58+
```shell
59+
ssh-keygen -t ed25519 -f sentinel-ca -C sentinel-CA
60+
```
61+
62+
**The key must not have a password** - this will be improved in a future release
63+
64+
### Adding users
65+
66+
Once you have the service installed you'll need to add some users. I hope to improve this process later but for now you can do it via the `admin` command
67+
68+
```shell
69+
./ssh-sentinel-server admin -h
70+
Create / delete users
71+
72+
Usage:
73+
ssh-sentinel-server admin [flags]
74+
75+
Flags:
76+
-c, --config string Config file
77+
-C, --create If set a new user will be created
78+
-h, --help help for admin
79+
-n, --name string User's name
80+
-P, --principals strings A list of principals for the user
81+
-U, --username string Username
82+
```
83+
84+
So to add a user
85+
86+
```shell
87+
./ssh-sentinel-server admin -c config.json -C -n test -P test1 test2 -U test
88+
```
89+
90+
Not that the username is the user associated with this service. The principals list the allowed usernames on the server you will ssh to.
91+
92+
## Usage
93+
94+
Here are some high level usage details
95+
96+
### Clients
97+
98+
The server stands up as a restful HTTP/S service. You can post requests via curl ( see [api docs](./api-docs.yaml) for the API ) or you can use the [CLI client](https://github.com/ST2Projects/ssh-sentinel-client)
99+
100+
### Servers
101+
102+
Servers require some configuration to use the CA. In short:
103+
104+
- Copy the CA **public key** to the server and save it in `/etc/ssh/ca.pub`
105+
- Edit `/etc/ssh/sshd_config` and add `TrustedUserCAKeys /etc/ssh/ca.pub`
106+
- Restart SSHD `service sshd restart`
107+
108+
The easiest way to do this across an estate is with ansible. I will publish a role on ansible-galaxy to do this but you can create your own if required / desired
43109
44110
## Releases
45111

api-docs.yaml

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
swagger: "2.0"
2+
info:
3+
title: SSH-Sentinel
4+
description: Sentinel API
5+
version: 1.0.0
6+
host: localhost:443
7+
consumes:
8+
- application/json
9+
produces:
10+
- application/json
11+
- text/plain
12+
schemes:
13+
- https
14+
basePath: /
15+
16+
definitions:
17+
KeySignRequest:
18+
type: object
19+
description: A signing request
20+
properties:
21+
username:
22+
type: string
23+
example: testUser-1
24+
description: The client username ( with the service )
25+
api_key:
26+
type: string
27+
pattern: [a-z0-9]{8}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{12}
28+
example: c7ce5f4a-ae6b-4232-a458-62855d0b9f29
29+
description: The API Key provided by the service at registration
30+
principals:
31+
type: array
32+
description: A list of usernames to be included with the certificate. Usernames are with the target services
33+
key:
34+
type: string
35+
description: The public key to sign
36+
KeySignResponse:
37+
type: object
38+
description: A signing response
39+
properties:
40+
success:
41+
type: boolean
42+
description: Indicates if the the request was a success
43+
example: false
44+
message:
45+
type: string
46+
description: Any message / info returned by the server ( e.g. an error message )
47+
example: "Authentication failure"
48+
signedKey:
49+
type: string
50+
description: The signed key / certificate
51+
notBefore:
52+
type: integer
53+
description: UNIX Epoch of the certificate start time
54+
example: 1666793056
55+
notAfter:
56+
type: integer
57+
description: UNIX Epoch of the certificate end time
58+
example: 1666793056
59+
Pong:
60+
type: string
61+
CAPubKey:
62+
type: string
63+
64+
65+
66+
paths:
67+
/ping:
68+
get:
69+
summary: A Ping test
70+
produces:
71+
- text/plain
72+
security: []
73+
responses:
74+
200:
75+
description: A successful response
76+
schema:
77+
$ref: "#/definitions/Pong"
78+
headers:
79+
content-type:
80+
type: string
81+
x-example: text/plain; charset=utf-8
82+
/ssh:
83+
post:
84+
summary: Performs signing
85+
produces:
86+
- application/json
87+
security: []
88+
parameters:
89+
- name: Request body
90+
in: body
91+
required: true
92+
schema:
93+
$ref: "#/definitions/KeySignRequest"
94+
responses:
95+
200:
96+
description: Successful request
97+
schema:
98+
$ref: "#/definitions/KeySignResponse"
99+
401:
100+
description: Unauthorized
101+
schema:
102+
$ref: "#/definitions/KeySignResponse"
103+
/capubkey:
104+
get:
105+
summary: Get the current CA public key
106+
produces:
107+
- text/plain
108+
security: []
109+
responses:
110+
200:
111+
description: A successful response
112+
schema:
113+
$ref: "#/definitions/CAPubKey"

install/Makefile

Lines changed: 0 additions & 8 deletions
This file was deleted.

0 commit comments

Comments
 (0)