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, } }
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 }
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 }