Skip to content

Commit 1c6edea

Browse files
authored
Merge pull request #13 from ST2Projects/tk/client-prep
Tk/client prep
2 parents 1562be8 + 47e87cf commit 1c6edea

20 files changed

+112
-57
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,4 +171,4 @@ fabric.properties
171171

172172
resources
173173
dist/
174-
./ssh-sentinel-server
174+
ssh-sentinel-server

.goreleaser.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ archives:
1616
linux: Linux
1717
386: i386
1818
amd64: x86_64
19+
files:
20+
- samples
21+
- README.md
22+
- LICENSE
23+
- install/Makefile
1924
checksum:
2025
name_template: 'checksums.txt'
2126
snapshot:

README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,35 @@ A simple to use and deploy SSH CA server.
66

77
Once ready, I will update the README and provide some more info in terms of usage and deployment
88

9+
## Installation
10+
11+
The release archive contains the binary `ssh-sentinel-server` and a samples directory containing a config template and a systemd service file.
12+
13+
You **will** need to edit the `config.json` to suit your needs. You may need to edit the service file depending on your OS.
14+
15+
To install, unpack the archive into the `/opt` directory then run the then install
16+
17+
```shell
18+
mkdir /opt/sentinel
19+
# Copy archive into directory
20+
tar xvzf ssh-sentinel-server_$VERSION_$ARCH.tar.gz
21+
22+
make install
23+
```
24+
25+
## Configuration
26+
27+
Configuration is defined in the `config.json`. Properties are explained below. All paths are relative to the `resources` directory
28+
29+
- `CAPrivateKey` - Name of the CA private key. The key must be unencrypted - a future enhancement will allow encrypted keys
30+
- `CAPublicKey` - Name of the CA public key.
31+
- `MaxValidTime` - Maximum lifespan of signed keys, in the normal [go duration format](https://pkg.go.dev/time#ParseDuration)
32+
- `db.dialect` - Must be `sqlite3`. A future release will add support for other DBs
33+
- `db.username` - Username of the DB user
34+
- `db.password` - Password of the DB user
35+
- `db.connection` - Connection URL for the DB. For sqlite3 this is a file path
36+
- `db.dbName` - Name of the DB
37+
938
## Goals
1039

1140
There are a couple of SSH CA servers out there - I have found them all difficult to use and have specific platform

app/admin_runner.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ package app
22

33
import (
44
log "github.com/sirupsen/logrus"
5-
"ssh-sentinel-server/config"
6-
"ssh-sentinel-server/model/db"
7-
"ssh-sentinel-server/sql"
5+
"github.com/st2projects/ssh-sentinel-server/config"
6+
"github.com/st2projects/ssh-sentinel-server/model/db"
7+
"github.com/st2projects/ssh-sentinel-server/sql"
88
)
99

1010
func RunAdmin(configPath string, createUser bool, name string, username string, principals []string) {

app/initialiser.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@ package app
22

33
import (
44
log "github.com/sirupsen/logrus"
5-
"ssh-sentinel-server/config"
6-
"ssh-sentinel-server/server"
7-
"ssh-sentinel-server/sql"
5+
"github.com/st2projects/ssh-sentinel-server/config"
6+
"github.com/st2projects/ssh-sentinel-server/model"
7+
"github.com/st2projects/ssh-sentinel-server/server"
8+
"github.com/st2projects/ssh-sentinel-server/sql"
89
)
910

10-
func InitialiseApp(configPath string, devMode bool) {
11+
func InitialiseApp(configPath string, devMode bool, httpConfig *model.HTTPConfig) {
1112

1213
customLogFormat := new(log.TextFormatter)
1314
customLogFormat.TimestampFormat = "2022-01-01 01:01:01.123"
@@ -19,5 +20,5 @@ func InitialiseApp(configPath string, devMode bool) {
1920
config.MakeConfig(configPath, devMode)
2021
sql.Connect()
2122

22-
server.Serve()
23+
server.Serve(httpConfig)
2324
}

cmd/admin.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package cmd
22

33
import (
44
"github.com/spf13/cobra"
5-
"ssh-sentinel-server/app"
5+
"github.com/st2projects/ssh-sentinel-server/app"
66
)
77

88
var create bool

cmd/serve.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,29 @@ package cmd
22

33
import (
44
"github.com/spf13/cobra"
5-
"ssh-sentinel-server/app"
5+
"github.com/st2projects/ssh-sentinel-server/app"
6+
"github.com/st2projects/ssh-sentinel-server/model"
67
)
78

89
var devMode bool
910

11+
var httpConfig = model.HTTPConfig{}.Default()
12+
1013
// serveCmd represents the serve command
1114
var serveCmd = &cobra.Command{
1215
Use: "serve",
1316
Short: "Start the CA server",
1417
Run: func(cmd *cobra.Command, args []string) {
15-
app.InitialiseApp(configPath, devMode)
18+
app.InitialiseApp(configPath, devMode, httpConfig)
1619
},
1720
}
1821

1922
func init() {
23+
2024
rootCmd.AddCommand(serveCmd)
2125
serveCmd.Flags().StringVarP(&configPath, "config", "c", "", "Config file")
26+
serveCmd.Flags().IntVarP(&httpConfig.HttpsPort, "https-port", "s", 443, "HTTPS Port")
27+
serveCmd.Flags().IntVarP(&httpConfig.HttpPort, "http-port", "i", 80, "HTTP Port")
2228
serveCmd.Flags().BoolVarP(&devMode, "dev-mode", "d", false, "Run in DEV mode. See README for implications")
2329

2430
serveCmd.MarkFlagRequired("config")

go.mod

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module ssh-sentinel-server
1+
module github.com/st2projects/ssh-sentinel-server
22

33
go 1.18
44

@@ -10,6 +10,7 @@ require (
1010
github.com/justinas/alice v1.2.0
1111
github.com/sirupsen/logrus v1.9.0
1212
github.com/spf13/cobra v1.5.0
13+
github.com/st2projects/ssh-sentinel-core v1.0.0
1314
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d
1415
golang.org/x/net v0.0.0-20220624214902-1bab6f366d9e
1516
gorm.io/driver/sqlite v1.3.6

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -732,6 +732,8 @@ github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
732732
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
733733
github.com/spf13/viper v1.7.0/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5qpdg=
734734
github.com/spf13/viper v1.7.1/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5qpdg=
735+
github.com/st2projects/ssh-sentinel-core v1.0.0 h1:9MKquOBeExd660PWkJ221pIa6qw11Bvec9TfA90W1os=
736+
github.com/st2projects/ssh-sentinel-core v1.0.0/go.mod h1:x7Lj7JO1u4BT0iWnj66eIbn9fqQD1qB2ollTFsVzzHg=
735737
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
736738
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
737739
github.com/stretchr/objx v0.3.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE=

install/Makefile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
install:
2+
cp -a samples/config.json .
3+
mkdir -p resources
4+
cp samples/ssh-sentinel.service /etc/systemd/system/ssh-sentinel.service
5+
systemctl daemon-reload
6+
7+
echo "Config file copied to ${PWD}/config.json. Please edit it before starting the service"
8+
echo "To start the service run systemctl start ssh-sentinel - To enable start on boot: systemctl enable ssh-sentinel"

0 commit comments

Comments
 (0)