sshgate

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2013 License: MIT Imports: 8 Imported by: 0

README

sshgate

Utility to ease the creation of SSH based applications in go

Examples of use

  • See this Demo ( app.go ) of sshgate which accept git push/pull operations
  • Authenticate users from database
  • Route push/pull to the right back-end (our primary use case)
  • Single entry point for your cluster of servers
  • ...

How to use?

The idea is to create an authentication function that will receive the user creadentials and return if the connection is allowed and an object that implement one of sshgate interfaces. type Authenticate func(c sshgate.Connection, user, algo string, pubkey []byte) (bool, sshgate.App)

The Demo implement sshgate.Executable to allow the clients to execute git-upload-pack and git-receive-pack.

  • First, sshgate query the app to check if the execution should be allowed with Executable.CanExec
  • If the response is yes, the command is executed by Executable.Exec

TODOs

  • Add support for password based authentication
  • Add more interfaces to expose more features of SSH

Caveats

In GO, SSH is a first class citizen with support for the protocol from go.crypto/ssh, but a lot of features are not exposed in the server API. For example, the package doesn't allow to send program's exit code to the client and this makes git complain that The remote end hung up unexpectedly... There is an issue about that opened at the same time I was working on the project.

Furthermore if the server hasn't read all the data before io.EOF is received, ssh won't let us read the data. I've opened an issue about that.

Please star those issues :)

For the meantime, sshgate use my fork of go.crypto/ssh

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MapToEnviron

func MapToEnviron(m map[string]string) (env []string)

Types

type App

type App interface {
}

type Authenticate

type Authenticate func(c Connection, user, algo string, pubkey []byte) (bool, App)

type BaseApp

type BaseApp struct {
}

type Connection

type Connection interface {
	net.Conn
}

type Executable

type Executable interface {
	App
	CanExec(cmd string, args []string, env map[string]string) bool
	Exec(cmd string, args []string, env map[string]string, stdin io.Reader, stdout, stderr io.Writer) int
}

type Server

type Server interface {
	Listen(addr string, port int) error
}

func NewServer

func NewServer(key []byte, cb Authenticate) (Server, error)

Jump to

Keyboard shortcuts

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