move agent socket dial to client connection creation

This commit is contained in:
William Banfield
2022-12-01 11:17:03 -05:00
parent 1a2afa62c5
commit 9c8c6c4cff
2 changed files with 8 additions and 9 deletions
+7 -1
View File
@@ -1,6 +1,7 @@
package ssh
import (
"net"
"os"
"path/filepath"
@@ -23,7 +24,12 @@ func Exec(cfg *ssh.ClientConfig, addr, cmd string) error {
return nil
}
func NewClientConfig(ac agent.ExtendedAgent) (*ssh.ClientConfig, error) {
func NewClientConfig() (*ssh.ClientConfig, error) {
c, err := net.Dial("unix", os.Getenv("SSH_AUTH_SOCK"))
if err != nil {
return nil, err
}
ac := agent.NewClient(c)
hkc, err := knownhosts.New(filepath.Join(os.Getenv("HOME"), ".ssh", "known_hosts"))
if err != nil {
return nil, err