示例#1
0
文件: ssh.go 项目: natacado/fleet
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,
	}
}
示例#2
0
文件: ssh.go 项目: 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
}
示例#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
}