deploy

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2025 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

package deploy provides functionality for connecting to remote hosts via SSH and managing their authorized_keys files. This file contains the Unix-specific implementation for locating the SSH agent.

package deploy provides functionality for connecting to remote hosts via SSH and managing their authorized_keys files. This file contains the logic for generating the content of an authorized_keys file from database records.

package deploy provides functionality for connecting to remote hosts via SSH and managing their authorized_keys files. This file contains the logic for importing public keys from a remote host's authorized_keys file into the Keymaster database.

package deploy provides functionality for connecting to remote hosts via SSH and managing their authorized_keys files. This file contains the core SSH and SFTP client logic for connecting, authenticating, and transferring files.

Index

Constants

View Source
const SystemKeyRestrictions = "command=\"internal-sftp\",no-port-forwarding,no-x11-forwarding,no-agent-forwarding,no-pty"

SystemKeyRestrictions defines the SSH options applied to the Keymaster system key. These restrictions limit the key to only allow SFTP access for file management, enhancing security by preventing shell access, port forwarding, etc.

Variables

View Source
var ErrHostKeySuccessfullyRetrieved = errors.New("keymaster: successfully retrieved host key")

ErrHostKeySuccessfullyRetrieved is a sentinel error used to gracefully stop the SSH handshake in GetRemoteHostKey once the host key has been captured.

Functions

func GenerateKeysContent

func GenerateKeysContent(accountID int) (string, error)

GenerateKeysContent constructs the authorized_keys file content for a given account. It combines the active system key, global user keys, and account-specific keys.

func GetRemoteHostKey

func GetRemoteHostKey(host string) (ssh.PublicKey, error)

GetRemoteHostKey connects to a host just to retrieve its public key.

func ImportRemoteKeys

func ImportRemoteKeys(account model.Account) (importedKeys []model.PublicKey, skippedCount int, warning string, err error)

ImportRemoteKeys connects to a host, reads its authorized_keys, imports new keys into the database, and returns the newly imported keys.

Types

type Deployer

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

Deployer handles the connection and deployment to a remote host.

func NewDeployer

func NewDeployer(host, user, privateKey string) (*Deployer, error)

NewDeployer creates a new SSH connection and returns a Deployer.

func (*Deployer) Close

func (d *Deployer) Close()

Close closes the underlying SSH and SFTP clients.

func (*Deployer) DeployAuthorizedKeys

func (d *Deployer) DeployAuthorizedKeys(content string) error

DeployAuthorizedKeys uploads the new authorized_keys content and moves it into place. This function uses a pure-SFTP method to be compatible with restricted keys (e.g., command="internal-sftp"). It uses a backup-and-rename strategy for compatibility with SFTP servers that don't support atomic overwrites (e.g., on Windows).

func (*Deployer) GetAuthorizedKeys

func (d *Deployer) GetAuthorizedKeys() ([]byte, error)

GetAuthorizedKeys reads and returns the content of the remote authorized_keys file.

Jump to

Keyboard shortcuts

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