security

package
v0.4.8 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2023 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package security is used to create key-pairs and tunnel database connections in the local aws env for development

Index

Constants

View Source
const (
	DefaultBitSize = 2048
	EnvSSHAuthSock = "SSH_AUTH_SOCK"
)

Variables

This section is empty.

Functions

func AuthMethodFromPrivateKeyFile

func AuthMethodFromPrivateKeyFile(file string) (ssh.AuthMethod, error)

func AuthMethodFromSSHAgent

func AuthMethodFromSSHAgent(sshAuthSock string) (ssh.AuthMethod, error)

func GenerateRsaKeyPair

func GenerateRsaKeyPair(size ...int) (*rsa.PrivateKey, *rsa.PublicKey, error)

func GenerateRsaPrivateKey

func GenerateRsaPrivateKey(size ...int) (*rsa.PrivateKey, error)

func MarshalRSAPrivate

func MarshalRSAPrivate(p *rsa.PrivateKey) []byte

MarshalRSAPrivate allows you to convert your private key to the right format to be saved to a file or used in other tooling systems.

func MarshalRSAPublic

func MarshalRSAPublic(pub ssh.PublicKey) []byte

MarshalRSAPublic converts the ssh.PublicKey to bytes. Sometimes you want to save the public part in a format readable by OpenSSH to grant access to a user. It is usually the format you can find in the ~/.ssh/authorized_keys file.

func NewConnectionWaiter

func NewConnectionWaiter(listener net.Listener, c chan net.Conn) error

func ParseRsaPrivateKeyFromPem

func ParseRsaPrivateKeyFromPem(data []byte) (*rsa.PrivateKey, error)

ParseRsaPrivateKeyFromPem converts bytes from a pem file, extracts the private key and returns it.

func ParseRsaPublicKeyFromPEM

func ParseRsaPublicKeyFromPEM(data []byte) (*rsa.PublicKey, error)

ParseRsaPublicKeyFromPEM converts bytes from a pem file, extracts the public key and returns it

func PrivateKeyToString

func PrivateKeyToString(privKey *rsa.PrivateKey) string

func PublicKeyToString

func PublicKeyToString(k *rsa.PublicKey) (string, error)

func UnmarshalRSAPublic

func UnmarshalRSAPublic(bytes []byte) (ssh.PublicKey, error)

Types

type Endpoint

type Endpoint struct {
	User string
	Host string
	Port int
}

func NewEndpoint

func NewEndpoint(s string) (*Endpoint, error)

func (*Endpoint) String

func (e *Endpoint) String() string

type KeyPairClient

type KeyPairClient struct {
	BitSize int
}

func (*KeyPairClient) GeneratePrivateKey

func (c *KeyPairClient) GeneratePrivateKey() (*rsa.PrivateKey, error)

func (*KeyPairClient) GenerateSaveKeyPair

func (c *KeyPairClient) GenerateSaveKeyPair(privFile, pubFile, name string) (sls.KeyPair, error)

func (*KeyPairClient) KeyPairFromPEM

func (c *KeyPairClient) KeyPairFromPEM(name string, pem []byte) (sls.KeyPair, error)

func (*KeyPairClient) LoadExistingKeyPair

func (c *KeyPairClient) LoadExistingKeyPair(filename string, name string) (sls.KeyPair, error)

func (*KeyPairClient) PrivateKeyString

func (c *KeyPairClient) PrivateKeyString(p *rsa.PrivateKey) string

func (*KeyPairClient) PublicKeyFromPEM

func (c *KeyPairClient) PublicKeyFromPEM(pubPEM []byte) (*rsa.PublicKey, error)

func (*KeyPairClient) PublicKeyString

func (c *KeyPairClient) PublicKeyString(p *rsa.PublicKey) (string, error)

type Printable

type Printable interface {
	Printf(string, ...interface{})
}

type SSHTunnel

type SSHTunnel struct {
	Local       *Endpoint
	Server      *Endpoint
	Remote      *Endpoint
	Config      *ssh.ClientConfig
	Log         Printable
	Conns       []net.Conn
	ServerConns []*ssh.Client
	// contains filtered or unexported fields
}

func NewSSHTunnel

func NewSSHTunnel(tunnel string, auth ssh.AuthMethod, dest string, localPort string) (*SSHTunnel, error)

func (*SSHTunnel) Close

func (t *SSHTunnel) Close()

func (*SSHTunnel) Logf

func (t *SSHTunnel) Logf(fmt string, args ...interface{})

func (*SSHTunnel) Start

func (t *SSHTunnel) Start()

Jump to

Keyboard shortcuts

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