mirror of
https://github.com/moul/sshportal.git
synced 2025-09-08 21:55:56 +08:00
Moved demo code in the README as example
This commit is contained in:
parent
328bb0153b
commit
4cf73e3410
4 changed files with 44 additions and 37 deletions
2
Makefile
2
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:
|
||||
|
|
46
README.md
46
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=<value>` 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
|
||||
```
|
||||
|
|
24
dbinit.go
24
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
|
||||
}
|
||||
|
|
9
main.go
9
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) {
|
||||
|
|
Loading…
Add table
Reference in a new issue