Documentation
¶
Overview ¶
The sshagent package provides an OS independent way to connect to a running "ssh-agent" process which returns an *Agent that is a wrapper for agent.ExtendedAgent.
On Windows, named pipes are used to connect to a local "ssh-agent", while on other platforms the "SSH_AUTH_SOCK" environment variable is expected to contain the path to a unix socket in order to communicate with the running "ssh-agent".
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Agent ¶
type Agent struct {
agent.ExtendedAgent
}
Agent wraps agent.ExtendedAgent
func NewAgent ¶
NewAgent connects to a local SSH agent either via unix socket or named pipes depending on the OS
In the case of a non-Windows OS, the "SSH_AUTH_SOCK" environment variable must be set or the process will fail.
On Windows a connection is attempted to "\\.\pipe\openssh-ssh-agent" which is the default named pipe path for the native OpenSSH Authentication Agent.
Example ¶
This example shows connecting to an existing agent and listing all identities from it.
This will fail unless a local SSH agent is running
package main
import (
"fmt"
"github.com/andrewheberle/sshagent"
)
func main() {
client, err := sshagent.NewAgent()
if err != nil {
fmt.Printf("error connecting to agent")
return
}
if _, err := client.List(); err != nil {
fmt.Printf("error listing keys from agent")
}
}
Output: error connecting to agent