# README
sshc

sshc.NewClient()
returns *ssh.Client
using ssh_config(5)
Usage
Describe ~/.ssh/config
.
Host myhost
HostName 203.0.113.1
User k1low
Port 10022
IdentityFile ~/.ssh/myhost_rsa
Use sshc.NewClient()
as follows
package main
import (
"bytes"
"log"
"github.com/k1LoW/sshc/v4"
)
func main() {
client, err := sshc.NewClient("myhost")
if err != nil {
log.Fatalf("error: %v", err)
}
session, err := client.NewSession()
if err != nil {
log.Fatalf("error: %v", err)
}
defer session.Close()
var stdout = &bytes.Buffer{}
session.Stdout = stdout
err = session.Run("hostname")
if err != nil {
log.Fatalf("error: %v", err)
}
log.Printf("result: %s", stdout.String())
}
sshc.Option
client, err := sshc.NewClient("myhost", User("k1low"), Port(1022))
See godoc page
Supported ssh_config keywords
- Hostname
- Port
- User
- IdentityFile
- ProxyCommand
- ProxyJump
References
# Functions
AppendConfigData returns Option that append ssh_config data to Config.configs.
AppendConfigPath returns Option that append ssh_config path to Config.configs.
AuthMethod returns Option that append ssh.AuthMethod to Config.auth.
ClearConfig returns Option thet clear Config.configs,.
ConfigData returns Option that unshift ssh_config data to Config.configs (alias of UnshiftConfigPath).
ConfigPath returns Option that unshift ssh_config path to Config.configs (alias of UnshiftConfigPath).
Dial returns *ssh.Client using Config.
DialTimeoutFunc returns Option that set Config.dialTimeoutFunc for set SSH client dial func.
Hostname returns Option that set Config.hostname for override SSH client port.
IdentityFile returns Option that append to Config.identityKeys for SSH client identity file.
IdentityFileWithPassphrase returns Option that append to Config.identityKeys for SSH client identity file.
IdentityKey returns Option that append to Config.identityKeys for SSH client identity file.
IdentityKeyWithPassphrase returns Option that append to Config.identityKeys for SSH client identity file.
Knownhosts returns Option that override Config.knownhosts.
NewClient reads ssh_config(5) ( Default is ~/.ssh/config and /etc/ssh/ssh_config ) and returns *ssh.Client.
NewConfig creates SSH client config.
Passphrase returns Option that set Config.passphrase for set SSH key passphrase.
Password returns Option that override Config.password.
Port returns Option that set Config.port for override SSH client port.
UnshiftConfigData returns Option that unshift ssh_config data to Config.configs.
UnshiftConfigPath returns Option that unshift ssh_config path to Config.configs.
UseAgent returns Option that override Config.useAgent.
User returns Option that set Config.user for override SSH client user.
# Structs
Config is the type for the SSH Client config.
No description provided by the author
No description provided by the author
# Type aliases
Option is the type for change Config.