Documentation ¶
Index ¶
Constants ¶
const DefaultSSHPort = 44338
DefaultSSHPort is the default SSH port of the NetBird's embedded SSH server
const RSAKeySize = 2048
RSAKeySize is a size of newly generated RSA key
const TerminalBackoffDelay = 500 * time.Millisecond
TerminalBackoffDelay is the delay between terminal session readiness checks
const TerminalTimeout = 10 * time.Second
TerminalTimeout is the timeout for terminal session to be ready
Variables ¶
This section is empty.
Functions ¶
func EncodePrivateKeyToPEM ¶
EncodePrivateKeyToPEM encodes Private Key from RSA to PEM format
func GeneratePrivateKey ¶
GeneratePrivateKey creates RSA Private Key of specified byte size
func GeneratePublicKey ¶
GeneratePublicKey returns the public part of the private key
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client wraps crypto/ssh Client to simplify usage
func Dial ¶
func Dial(network, addr string, config *ssh.ClientConfig) (*Client, error)
Dial connects to the remote SSH server.
func DialWithKey ¶
DialWithKey connects to the remote SSH server with a provided private key file (PEM).
func (*Client) OpenTerminal ¶
OpenTerminal starts an interactive terminal session with the remote SSH server
type DefaultServer ¶
type DefaultServer struct {
// contains filtered or unexported fields
}
DefaultServer is the embedded NetBird SSH server
func (*DefaultServer) AddAuthorizedKey ¶
func (srv *DefaultServer) AddAuthorizedKey(peer, newKey string) error
AddAuthorizedKey add a given peer key to server authorized keys
func (*DefaultServer) RemoveAuthorizedKey ¶
func (srv *DefaultServer) RemoveAuthorizedKey(peer string)
RemoveAuthorizedKey removes SSH key of a given peer from the authorized keys
func (*DefaultServer) Start ¶
func (srv *DefaultServer) Start() error
Start starts SSH server. Blocking
type KeyType ¶
type KeyType string
KeyType is a type of SSH key
const ECDSA KeyType = "ecdsa"
ECDSA is key of type ecdsa
const ED25519 KeyType = "ed25519"
ED25519 is key of type ed25519
const RSA KeyType = "rsa"
RSA is key of type rsa
type MockServer ¶
type MockServer struct { Ctx context.Context StopFunc func() error StartFunc func() error AddAuthorizedKeyFunc func(peer, newKey string) error RemoveAuthorizedKeyFunc func(peer string) }
MockServer mocks ssh.Server
func (*MockServer) AddAuthorizedKey ¶
func (srv *MockServer) AddAuthorizedKey(peer, newKey string) error
AddAuthorizedKey add a given peer key to server authorized keys
func (*MockServer) RemoveAuthorizedKey ¶
func (srv *MockServer) RemoveAuthorizedKey(peer string)
RemoveAuthorizedKey removes SSH key of a given peer from the authorized keys
type Server ¶
type Server interface { // Stop stops SSH server. Stop() error // Start starts SSH server. Blocking Start() error // RemoveAuthorizedKey removes SSH key of a given peer from the authorized keys RemoveAuthorizedKey(peer string) // AddAuthorizedKey add a given peer key to server authorized keys AddAuthorizedKey(peer, newKey string) error }
Server is an interface of SSH server