bunker

package module
v0.0.0-...-bdf0f64 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 2, 2024 License: MIT Imports: 40 Imported by: 0

README

bunker

A simple bastion system for linux hosts

Installation

From Binary

Visit GitHub Releases and download the latest release.

Static assets are embedded in the binary, so you don't need to download anything else.

  • Prepare a data directory and put bunker.yaml configuration file in it
  • Run bunker --data-dir data
From Container Image

Visit DockerHub Repository or GitHub Packages for container images

  • Prepare a data directory and put bunker.yaml configuration file in it
  • Run contaienr image with /data mounted, docker run -p 8080:8080 -p 8022:8022 -v $PWD/data:/data yankeguo/bunker:latest

Initial Users

Put a users.yaml file in data-dir to initialize the system with users.

username: yanke
password: qwerty
is_admin: true
update_existing: true
---
username: guest
password: guest

Configuration File

server:
  listen: ":8080"
ssh_server:
  listen: ":8022"

Credits

GUO YANKE, MIT License

Documentation

Index

Constants

This section is empty.

Variables

View Source
var STATIC embed.FS

Functions

func CreateDatabase

func CreateDatabase(dir DataDir) (db *gorm.DB, err error)

func Debug

func Debug(name string) bool

func InitializeUsers

func InitializeUsers(
	log *zap.SugaredLogger,
	dir DataDir,
	_db *gorm.DB,
) (err error)

func InstallAppToRouter

func InstallAppToRouter(a *App, ur ufx.Router)

func InstallSignersToRouter

func InstallSignersToRouter(ur ufx.Router, signers *Signers)

func InstallStaticToRouter

func InstallStaticToRouter(ur ufx.Router)

func PipeSSH

func PipeSSH(log *zap.SugaredLogger, target *ssh.Client, userConn *ssh.ServerConn, chUserNewChannel <-chan ssh.NewChannel, chUserRequest <-chan *ssh.Request)

Types

type App

type App struct {
	// contains filtered or unexported fields
}

func CreateApp

func CreateApp(opts AppOptions) (app *App, err error)

type AppOptions

type AppOptions struct {
	fx.In

	DB *gorm.DB
}

type DataDir

type DataDir string

func (DataDir) String

func (d DataDir) String() string

type SSHPrivateKeyGenerator

type SSHPrivateKeyGenerator = func() (key crypto.PrivateKey, err error)

type SSHServer

type SSHServer struct {
	// contains filtered or unexported fields
}

func CreateSSHServer

func CreateSSHServer(opts SSHServerOptions) (s *SSHServer, err error)

func (*SSHServer) AuthLogCallback

func (s *SSHServer) AuthLogCallback(conn ssh.ConnMetadata, method string, err error)

func (*SSHServer) BannerCallback

func (s *SSHServer) BannerCallback(conn ssh.ConnMetadata) string

func (*SSHServer) HandleServerConn

func (s *SSHServer) HandleServerConn(conn net.Conn)

func (*SSHServer) ListenAndServe

func (s *SSHServer) ListenAndServe() (err error)

func (*SSHServer) PublicKeyCallback

func (s *SSHServer) PublicKeyCallback(conn ssh.ConnMetadata, _key ssh.PublicKey) (perm *ssh.Permissions, err error)

func (*SSHServer) Shutdown

func (s *SSHServer) Shutdown(ctx context.Context) (err error)

type SSHServerOptions

type SSHServerOptions struct {
	fx.In

	Lifecycle fx.Lifecycle
	Conf      ufx.Conf
	DataDir   DataDir
	DB        *gorm.DB
	Signers   *Signers
	Logger    *zap.SugaredLogger
}

type Signers

type Signers struct {
	Host   []ssh.Signer
	Client []ssh.Signer

	AuthorizedKeys string
}

func CreateSigners

func CreateSigners(log *zap.SugaredLogger, dir DataDir) (signers *Signers, err error)

Directories

Path Synopsis
cmd
dao
scripts

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL