package ssh
import "git.sr.ht/~shulhan/pakakeh.go/lib/ssh"
Package ssh provide a wrapper for golang.org/x/crypto/ssh and a parser for SSH client configuration specification ssh_config(5).
Index ¶
- type Client
- func NewClientInteractive(section *sshconfig.Section) (cl *Client, err error)
- func (cl *Client) Close() (err error)
- func (cl *Client) Execute(ctx context.Context, cmd string) (err error)
- func (cl *Client) Output(cmd string) (stdout, stderr []byte, err error)
- func (cl *Client) ScpGet(remote, local string) (err error)
- func (cl *Client) ScpPut(local, remote string) (err error)
- func (cl *Client) SetSessionOutputError(stdout, stderr io.Writer)
- func (cl *Client) String() string
Types ¶
type Client ¶
Client for SSH connection.
func NewClientInteractive ¶
NewClientInteractive create a new SSH connection using predefined configuration, possibly interactively.
This function may dial twice to find appropriate authentication method when SSH_AUTH_SOCK environment variable is set but no valid key exist and IdentityFile directive is specified in the Host section.
If the IdentityFile is encrypted, it will prompt for passphrase in terminal or from program defined in SSH_ASKPASS, see crypto.LoadPrivateKeyInteractive for more information.
The following section keys are recognized and implemented by Client,
- Hostname
- IdentityAgent
- IdentityFile
- Port
- User
- UserKnownHostsFile, setting this to "none" will set HostKeyCallback to ssh.InsecureIgnoreHostKey.
func (*Client) Close ¶
Close the client connection and release all resources.
func (*Client) Execute ¶
Execute a command on remote server.
func (*Client) Output ¶
Output run the command and return its standard output and error as is. Any other error beside standard error, like connection, will be returned as error.
func (*Client) ScpGet ¶
ScpGet copy file from remote into local storage using scp.
The local file should be use the absolute path, or relative to the file in sshconfig.Section.WorkingDir.
func (*Client) ScpPut ¶
ScpPut copy a file from local storage to remote using scp command.
The local file should be use the absolute path, or relative to the file in sshconfig.Section WorkingDir.
func (*Client) SetSessionOutputError ¶
SetSessionOutputError set the standard output and error for future remote execution.
func (*Client) String ¶
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
lib/ssh/sftp | Package sftp implement SSH File Transfer Protocol v3 as defined in [draft-ietf-secsh-filexfer-02.txt]. |
- Version
- v0.60.0 (latest)
- Published
- Feb 1, 2025
- Platform
- linux/amd64
- Imports
- 15 packages
- Last checked
- 9 hours ago –
Tools for package owners.