sshdb

package
v0.34.2 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2025 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MySQLViaSSHDialer

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

MySQLViaSSHDialer used to register the database connection via the ssh tunnel.

func (*MySQLViaSSHDialer) Dial

func (m *MySQLViaSSHDialer) Dial(addr string) (net.Conn, error)

type Option

type Option func(*SSHConfig)

func WithDBDURL

func WithDBDURL(url string) Option

func WithDBDriver

func WithDBDriver(driver string) Option

func WithKnownHostsPath

func WithKnownHostsPath(knownHostsPath string) Option

func WithPass

func WithPass(sshPass string) Option

func WithSSHKeyFile

func WithSSHKeyFile(sshKeyFile string) Option

func WithSSHKeyPass

func WithSSHKeyPass(sshKeyPass string) Option

func WithSSHUser

func WithSSHUser(sshUser string) Option

func WithSShHost

func WithSShHost(sshHost string) Option

func WithSShPort

func WithSShPort(sshPort string) Option

type PostgresViaSSHDialer

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

PostgresViaSSHDialer implements the driver.Driver interface to register the connection to the database via the ssh tunnel.

func (*PostgresViaSSHDialer) Dial

func (sd *PostgresViaSSHDialer) Dial(network, address string) (net.Conn, error)

func (*PostgresViaSSHDialer) DialTimeout

func (sd *PostgresViaSSHDialer) DialTimeout(
	network, address string,
	timeout time.Duration,
) (net.Conn, error)

func (*PostgresViaSSHDialer) Open

func (sd *PostgresViaSSHDialer) Open(s string) (_ driver.Conn, err error)

type SSHConfig

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

SSHConfig struct setup the ssh tunnel to connect with a given database.

func New

func New(opts ...Option) *SSHConfig

func (*SSHConfig) Close

func (c *SSHConfig) Close() error

Close method closes the tcp connection.

func (*SSHConfig) SSHTunnel

func (c *SSHConfig) SSHTunnel() error

SSHTunnel method sets up the ssh tunnel and does a number of things: Create a ssh client config object that witht he user. Define a HostKeyCallback to ensures known ssh server is the actual server. If host key checking is ignore then any server that has the same FQDN or IP address can impersonate the actual ssh server. Define the authentication method to perform the ssh tunnel (passsword or private key). Register the ViaSSHDialer with the ssh connection as a parameter.

Jump to

Keyboard shortcuts

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