ssher

package module
v0.0.0-...-d36569c Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2019 License: Apache-2.0 Imports: 13 Imported by: 1

README

ssher

GoDoc Go Report Card

Easily create golang.org/x/crypto/ssh connections in golang, using values from your ssh config file.

Most people will already have configured their ssh connections once for openssh, so why do it again manually?

This package is essentially a wrapper around https://github.com/kevinburke/ssh_config, which attempts to automatically load all required values from your ~/.ssh/config.

Currently supported options:

  • Ciphers
  • ConnectTimeout
  • HostKeyAlgorithms
  • Hostname
  • IdentityFile
  • KexAlgorithms
  • MACs
  • Port
  • User
  • UserKnownHostsFile

Currently, only public key auth is attempted and only one IdentityFile will be used. Host key checking is enforced. Any limitations that apply to https://github.com/kevinburke/ssh_config also apply here (currently no support for +value syntax).

This module is not ready for production use.

Documentation

Overview

Package ssher allows you to easily create ssh connections in golang.

This package is essentially a wrapper around https://github.com/kevinburke/ssh_config, which attempts to automatically load all values required to create a https://golang.org/x/crypto/ssh ClientConfig from your ~/.ssh/config.

Most people will already have configured their ssh connections once for openssh, so why do it again manually?

Currently supported options:

  • Ciphers
  • ConnectTimeout
  • HostKeyAlgorithms
  • Hostname
  • IdentityFile
  • KexAlgorithms
  • MACs
  • Port
  • User
  • UserKnownHostsFile

Currently, only public key auth is attempted, and only the agent and one IdentityFile will be used.

Host key checking is enforced.

Any limitations that apply to https://github.com/kevinburke/ssh_config also apply here (currently no support for +value syntax).

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClientConfig

func ClientConfig(alias string, configFile string) (*ssh.ClientConfig, string, error)

ClientConfig takes in an ssh config file host alias and a path to an ssh config file, and returns an ssh.ClientConfig and a connection string (for dialing). If passed an empty string for the configFile, it will use the default config file paths: ~/.ssh/config and /etc/ssh/ssh_config

Example (Custom)
sshConfig, hostPort, err := ClientConfig("myhost.mydomain.com", "~/somedir/my_ssh_config")
if err != nil {
	// Handle error here...
}
_, err = ssh.Dial("tcp", hostPort, sshConfig)
if err != nil {
	// Handle error here...
}
Output:

Example (Defaults)
sshConfig, hostPort, err := ClientConfig("myhost.mydomain.com", "")
if err != nil {
	// Handle error here...
}
_, err = ssh.Dial("tcp", hostPort, sshConfig)
if err != nil {
	// Handle error here...
}
Output:

Types

This section is empty.

Jump to

Keyboard shortcuts

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