浏览文件
agent_unix.go
18 行 · 306 B历史下载| 1 | //go:build !windows |
| 2 | |
| 3 | package remotehost |
| 4 | |
| 5 | import ( |
| 6 | "context" |
| 7 | "errors" |
| 8 | "net" |
| 9 | "os" |
| 10 | ) |
| 11 | |
| 12 | func dialAgent(ctx context.Context) (net.Conn, error) { |
| 13 | path := os.Getenv("SSH_AUTH_SOCK") |
| 14 | if path == "" { |
| 15 | return nil, errors.New("SSH agent unavailable") |
| 16 | } |
| 17 | return (&net.Dialer{}).DialContext(ctx, "unix", path) |
| 18 | } |

