Example #1
0
func sshClientConfig(user string) *gossh.ClientConfig {
	agent, err := net.Dial("unix", os.Getenv("SSH_AUTH_SOCK"))
	if err != nil {
		return nil
	}

	auths := []gossh.ClientAuth{
		gossh.ClientAuthAgent(gossh.NewAgentClient(agent)),
	}

	return &gossh.ClientConfig{
		User: user,
		Auth: auths,
	}
}
Example #2
0
File: ssh.go Project: jsdir/fleet
func sshClientConfig(user string) (*gossh.ClientConfig, error) {
	agentClient, err := sshAgentClient()
	if err != nil {
		return nil, err
	}

	cfg := gossh.ClientConfig{
		User: user,
		Auth: []gossh.ClientAuth{
			gossh.ClientAuthAgent(agentClient),
		},
	}

	return &cfg, nil
}
Example #3
0
func sshClientConfig(user string) (*gossh.ClientConfig, error) {
	sock := os.Getenv("SSH_AUTH_SOCK")
	if sock == "" {
		return nil, errors.New("SSH_AUTH_SOCK environment variable is not set. Verify ssh-agent is running. See https://github.com/coreos/fleet/blob/master/Documentation/remote-access.md for help.")
	}

	agent, err := net.Dial("unix", sock)
	if err != nil {
		return nil, err
	}

	cfg := gossh.ClientConfig{
		User: user,
		Auth: []gossh.ClientAuth{
			gossh.ClientAuthAgent(gossh.NewAgentClient(agent)),
		},
	}

	return &cfg, nil
}