예제 #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
}