Created
September 14, 2018 02:55
-
-
Save eikenb/0a5831a6555d762f06b6b49676b9c48e to your computer and use it in GitHub Desktop.
ssh client key connect
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func keyConfig() ssh.ClientConfig { | |
PORT = "22" | |
sshagent, err := net.Dial("unix", os.Getenv("SSH_AUTH_SOCK")) | |
if err != nil { | |
panic(err) | |
} | |
signer := ssh.PublicKeysCallback(agent.NewClient(sshagent).Signers) | |
sshConfig := ssh.ClientConfig{ | |
User: os.ExpandEnv("$USER"), | |
Auth: []ssh.AuthMethod{signer}, | |
HostKeyCallback: ssh.InsecureIgnoreHostKey(), | |
} | |
sshConfig.SetDefaults() | |
return sshConfig | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment