Documentation
¶
Index ¶
- Constants
- func Quote(s string) string
- type Client
- func (c *Client) Close() error
- func (c *Client) Connect() error
- func (c *Client) Dial(network, addr string) (net.Conn, error)
- func (c *Client) MkdirAll(path string) error
- func (c *Client) RsyncSender(remoteCmd string, run func(io.ReadWriteCloser) error) error
- func (c *Client) RunCommand(cmd string) (string, error)
- func (c *Client) RunCommandWithOutput(cmd string, stdout, stderr io.Writer) error
- func (c *Client) UploadFile(localPath, remotePath string, mode os.FileMode) error
- type ClientOptions
- type Command
- type Executor
Constants ¶
const ( // DefaultSSHPort is the standard SSH port DefaultSSHPort = 22 // DefaultConnectTimeout is the default timeout for SSH connection establishment DefaultConnectTimeout = 30 * time.Second )
SSH connection defaults
const ( // DirPermissionsSSH is the permission mode for .ssh directory (rwx------) DirPermissionsSSH = 0700 // FilePermissionsKnownHosts is the permission mode for known_hosts file (rw-------) FilePermissionsKnownHosts = 0600 // FilePermissionsPrivateKey is the permission mode for SSH private keys (rw-------) FilePermissionsPrivateKey = 0600 )
File and directory permissions for SSH-related files
Variables ¶
This section is empty.
Functions ¶
func Quote ¶
Quote returns s wrapped so it is safe to interpolate as a single argument into a POSIX shell command line executed on the remote server.
Remote commands in shippy are built with fmt.Sprintf and run through the remote login shell (session.Run / CombinedOutput). Any value that is not a trusted literal — file paths derived from local filenames, deploy paths, shared entries, extracted database names, etc. — MUST be passed through Quote first, otherwise shell metacharacters in that value lead to command injection (CWE-78) on the deploy target.
The value is wrapped in single quotes, within which the shell treats every character literally. The only character that cannot appear inside single quotes is the single quote itself, so each embedded single quote is replaced by the standard close-quote, backslash-escaped-quote, reopen-quote sequence (see the ReplaceAll below).
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client represents an SSH client connection
func NewClientWithOptions ¶
func NewClientWithOptions(opts ClientOptions) (*Client, error)
NewClientWithOptions creates a new SSH client with full options
func (*Client) Dial ¶
Dial opens a connection to addr from the remote host. Used for SSH tunneling (e.g., connecting to a remote database).
func (*Client) MkdirAll ¶
MkdirAll creates a directory and all parent directories on the remote server
func (*Client) RsyncSender ¶ added in v0.2.0
RsyncSender starts remoteCmd (a remote `rsync --server ...` receiver) over the SSH connection and hands run an io.ReadWriteCloser wired to the command's stdin+stdout, so a local rsync client can speak the rsync protocol to the real remote rsync. Stderr from the remote rsync is captured and surfaced on failure.
func (*Client) RunCommand ¶
RunCommand executes a command on the remote server
func (*Client) RunCommandWithOutput ¶
RunCommandWithOutput executes a command and streams output to stdout/stderr
type ClientOptions ¶
type ClientOptions struct {
Host string
Port int
User string
KeyPath string
SSHOptions map[string]string
SSHMultiplexing bool
KnownHostsFile string
HostKeyFingerprint string
ProxyCommand string // optional: shell command to establish TCP transport (e.g. "/usr/bin/nc %h %p")
}
ClientOptions represents SSH client configuration options
type Command ¶
type Command struct {
Name string
Run string
// Context, when non-empty, is a subcontext-entry prefix (e.g.
// "docker exec php85"). The command — including the `cd` into the release
// directory — is wrapped as `<Context> sh -c '<cd workDir && Run>'` so it
// runs inside that context. Empty means run directly on the remote host.
Context string
}
Command represents a command to execute
type Executor ¶
type Executor struct {
// contains filtered or unexported fields
}
Executor handles command execution on remote servers
func NewExecutor ¶
NewExecutor creates a new command executor