From 4cf73e341055220da7944ef4d948619a9d35b317 Mon Sep 17 00:00:00 2001 From: Manfred Touron Date: Mon, 27 Nov 2017 07:54:48 +0100 Subject: [PATCH] Moved demo code in the README as example --- Makefile | 2 +- README.md | 46 +++++++++++++++++++++++++++++++++++++++++++--- dbinit.go | 24 ------------------------ main.go | 9 --------- 4 files changed, 44 insertions(+), 37 deletions(-) diff --git a/Makefile b/Makefile index 48fba5f..c72030b 100644 --- a/Makefile +++ b/Makefile @@ -25,7 +25,7 @@ _docker_install: .PHONY: dev dev: -go get github.com/githubnemo/CompileDaemon - CompileDaemon -exclude-dir=.git -exclude=".#*" -color=true -command="./sshportal --demo --debug --bind-address=:$(PORT) --aes-key=$(AES_KEY)" . + CompileDaemon -exclude-dir=.git -exclude=".#*" -color=true -command="./sshportal --debug --bind-address=:$(PORT) --aes-key=$(AES_KEY)" . .PHONY: test test: diff --git a/README.md b/README.md index 9c22c5d..8886b9f 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,7 @@ Jump host/Jump server without the jump, a.k.a Transparent SSH bastion * User invitations * Easy authorized_keys installation * Sensitive data encryption +* Session management ## Usage @@ -116,7 +117,7 @@ config> ## CLI -sshportal embeds a configuration CLI. +`sshportal` embeds a configuration CLI. By default, the configuration user is `admin`, (can be changed using `--config-user=` when starting the server. @@ -241,16 +242,39 @@ Get the latest version using GO. go get -u github.com/moul/sshportal ``` +## portal alias (.ssh/config) + +Edit your `~/.ssh/config` file (create it first if needed) + +```ini +Host portal + User admin + Port 2222 # portal port + HostName 127.0.0.1 # portal hostname +``` + +```bash +# you can now run a shell using this: +ssh portal +# instead of this: +ssh localhost -p 2222 -l admin + +# or connect to hosts using this: +ssh hostname@portal +# instead of this: +ssh localhost -p 2222 -l hostname +``` + ## Backup / Restore sshportal embeds built-in backup/restore methods which basically import/export JSON objects: ```sh # Backup -ssh admin@sshportal config backup > sshportal.bkp +ssh portal config backup > sshportal.bkp # Restore -ssh admin@sshportal config restore < sshportal.bkp +ssh portal config restore < sshportal.bkp ``` This method is particularly useful as it should be resistant against future DB schema changes (expected during development phase). @@ -264,3 +288,19 @@ sqlite3 sshportal.db .dump > sshportal.sql.bkp # or just the immortal cp cp sshportal.db sshportal.db.bkp ``` + +## Demo data + +The following servers are freely available, without external registration, +it makes it easier to quickly test `sshportal` without configuring your own servers to accept sshportal connections. + +``` +ssh portal host create new@sdf.org +ssh sdf@portal + +ssh portal host create test@whoami.filippo.io +ssh whoami@portal + +ssh portal host create test@chat.shazow.net +ssh chat@portal +``` diff --git a/dbinit.go b/dbinit.go index 0893b93..44c5b31 100644 --- a/dbinit.go +++ b/dbinit.go @@ -429,27 +429,3 @@ func dbInit(db *gorm.DB) error { } return nil } - -func dbDemo(db *gorm.DB) error { - var hostGroup HostGroup - if err := HostGroupsByIdentifiers(db, []string{"default"}).First(&hostGroup).Error; err != nil { - return err - } - - var key SSHKey - if err := SSHKeysByIdentifiers(db, []string{"default"}).First(&key).Error; err != nil { - return err - } - - var ( - host1 = Host{Name: "sdf", Addr: "sdf.org:22", User: "new", SSHKeyID: key.ID, Groups: []*HostGroup{&hostGroup}} - host2 = Host{Name: "whoami", Addr: "whoami.filippo.io:22", User: "test", SSHKeyID: key.ID, Groups: []*HostGroup{&hostGroup}} - host3 = Host{Name: "ssh-chat", Addr: "chat.shazow.net:22", User: "test", SSHKeyID: key.ID, Fingerprint: "MD5:e5:d5:d1:75:90:38:42:f6:c7:03:d7:d0:56:7d:6a:db", Groups: []*HostGroup{&hostGroup}} - ) - - // FIXME: check if hosts exist to avoid `UNIQUE constraint` error - db.FirstOrCreate(&host1) - db.FirstOrCreate(&host2) - db.FirstOrCreate(&host3) - return nil -} diff --git a/main.go b/main.go index 5bb9096..a2b62e8 100644 --- a/main.go +++ b/main.go @@ -52,10 +52,6 @@ func main() { Value: ":2222", Usage: "SSH server bind address", }, - cli.BoolFlag{ - Name: "demo", - Usage: "*unsafe* - demo mode: accept all connections", - }, /*cli.StringFlag{ Name: "db-driver", Value: "sqlite3", @@ -107,11 +103,6 @@ func server(c *cli.Context) error { if err := dbInit(db); err != nil { return err } - if c.Bool("demo") { - if err := dbDemo(db); err != nil { - return err - } - } // ssh server ssh.Handle(func(s ssh.Session) {