Documentation
¶
Index ¶
- func Configure(user, host string, signers ...ssh.Signer) *ssh.ClientConfig
- func Dial(user, host string, signers ...ssh.Signer) (*ssh.Client, error)
- func DialConfig(host string, config *ssh.ClientConfig) (*ssh.Client, error)
- func DialEach(user, host string, signers ...ssh.Signer) (*ssh.Client, ssh.Signer, error)
- func Exec(ssh *ssh.Client, cmd string) error
- func Run(ssh *ssh.Client, cmd string) (string, error)
- func Shell(sshc *ssh.Client, dir string, args ...string) error
- func Split(userHost string) (user string, host string, err error)
- func Test(user, host string, signers ...ssh.Signer) (ssh.Signer, error)
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Configure ¶
func Configure(user, host string, signers ...ssh.Signer) *ssh.ClientConfig
Configure creates a new *ClientConfig based on sensible defaults. This method is fairly error-resistent and intended for advanced use cases.
func Dial ¶
Dial creates a new ssh.Client with sensible defaults
Example ¶
package main import ( "github.com/matthewmueller/sshx" ) func main() { // Dial a server client, err := sshx.Dial("vagrant", "127.0.0.1:2222") if err != nil { panic(err) } defer client.Close() err = sshx.Exec(client, "echo 'sshx'") if err != nil { panic(err) } }
Output: sshx
func DialConfig ¶ added in v0.0.12
DialConfig creates a new ssh.Client with the provided ssh config
Example ¶
package main import ( "time" "github.com/matthewmueller/sshx" ) func main() { cfg := sshx.Configure("vagrant", "127.0.0.1:2222") cfg.Timeout = time.Second // Dial a server client, err := sshx.DialConfig("127.0.0.1:2222", cfg) if err != nil { panic(err) } defer client.Close() err = sshx.Exec(client, "echo 'sshx'") if err != nil { panic(err) } }
Output: sshx
func Test ¶ added in v0.0.7
Test the remote host connection, returning the first signer that was successfully used to connect to the remote host.
Example ¶
package main import ( "github.com/matthewmueller/sshx" ) func main() { // Dial a server signer, err := sshx.Test("vagrant", "127.0.0.1:2222") if err != nil { panic(err) } _ = signer.PublicKey() }
Output:
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.